Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated to openPDF 2.0.2 #662

Merged
merged 7 commits into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: maven

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ jobs:

steps:
- uses: actions/checkout@v4
- name: Set up JDK 8
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '8'
java-version: '17'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

XDocReport is working with Java 8 , why you need Java 17?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Java 17 is required for OpenPDF 2.0.0 or later. The build for this pull request fails with java 8. If we want to upgrade openpdf, I don't think there is another way than to upgrade the minimum java requirement for XDocReport. Of course I'm not sure if losing java 8 support is acceptable for this project.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if losing java 8 support is acceptable for this project.

No sorry, there are so many people who are using XDocReport with old Java version. We need to keep it.

@pascalleclercq do you know if we could build only the module of OpenPDF 2.0.0 with Java 17?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The maven compiler plugin is still set to version 1.7. So if we compile with java 17, XDocReport should still be compatible with java 8, unless you use the openpdf modules of course, right?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added the changes that would be needed to run the tests with jdk17.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry but the people staying on Java 8 just have to use the old Version of those libraries. For those who keep up to date there should be a release for OpenPDF 2.
You also could make separate Releases for Java 8

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry but the people staying on Java 8 just have to use the old Version of those libraries.

You speak about PDF converter, but XDocReport provides another feature like report generation.

distribution: 'temurin'
cache: maven
- name: Build with Maven
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-to-maven-central.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Set up Maven Central Repository
uses: actions/setup-java@v4
with:
java-version: 8
java-version: '17'
server-id: sonatype-nexus-staging
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,32 +24,6 @@
*/
package fr.opensagres.xdocreport.document.odt.styling;

import static org.junit.Assert.assertThat;

import java.io.IOException;
import java.io.InputStream;
import java.io.StringReader;
import java.io.StringWriter;
import java.io.Writer;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;

import org.junit.Assert;
import org.junit.Test;
import org.w3c.dom.Document;
import org.xml.sax.InputSource;
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.XMLReaderFactory;
import org.xmlunit.matchers.CompareMatcher;

import com.sun.org.apache.xml.internal.serializer.OutputPropertiesFactory;

import fr.opensagres.xdocreport.document.odt.preprocessor.ODTBufferedDocumentContentHandler;
import fr.opensagres.xdocreport.document.odt.preprocessor.ODTStyleContentHandler;
import fr.opensagres.xdocreport.document.odt.textstyling.MockContext;
Expand All @@ -59,6 +33,28 @@
import fr.opensagres.xdocreport.document.textstyling.IDocumentHandler;
import fr.opensagres.xdocreport.document.textstyling.ITextStylingTransformer;
import fr.opensagres.xdocreport.document.textstyling.html.HTMLTextStylingTransformer;
import org.junit.Assert;
import org.junit.Test;
import org.w3c.dom.Document;
import org.xml.sax.InputSource;
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.XMLReaderFactory;
import org.xmlunit.matchers.CompareMatcher;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import java.io.IOException;
import java.io.InputStream;
import java.io.StringReader;
import java.io.StringWriter;
import java.io.Writer;

import static org.junit.Assert.assertThat;

/**
* Check ODT Styling generation by comparing generated result against the expected XML
Expand Down Expand Up @@ -106,7 +102,7 @@ public String formatXML( String unformattedXml )
Transformer serializer = tfactory.newTransformer();

serializer.setOutputProperty( OutputKeys.INDENT, "yes" );
serializer.setOutputProperty( OutputPropertiesFactory.S_KEY_INDENT_AMOUNT, "2" );
serializer.setOutputProperty( "{http:// xml. apache. org/ xalan}indent-amount", "2" );
serializer.setOutputProperty( OutputKeys.STANDALONE, "no" );

Writer out = new StringWriter();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,13 @@
*/
package fr.opensagres.xdocreport.document.odt.textstyling;

import static org.junit.Assert.assertThat;

import java.io.IOException;
import java.io.InputStream;
import java.io.StringReader;
import java.io.StringWriter;
import java.io.Writer;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;

import fr.opensagres.xdocreport.document.odt.preprocessor.ODTBufferedDocumentContentHandler;
import fr.opensagres.xdocreport.document.odt.preprocessor.ODTStyleContentHandler;
import fr.opensagres.xdocreport.document.preprocessor.sax.BufferedDocument;
import fr.opensagres.xdocreport.document.preprocessor.sax.BufferedDocumentContentHandler;
import fr.opensagres.xdocreport.document.textstyling.IDocumentHandler;
import fr.opensagres.xdocreport.document.textstyling.ITextStylingTransformer;
import fr.opensagres.xdocreport.document.textstyling.html.HTMLTextStylingTransformer;
import org.junit.Assert;
import org.junit.Test;
import org.w3c.dom.Document;
Expand All @@ -48,15 +39,20 @@
import org.xml.sax.helpers.XMLReaderFactory;
import org.xmlunit.matchers.CompareMatcher;

import com.sun.org.apache.xml.internal.serializer.OutputPropertiesFactory;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import java.io.IOException;
import java.io.InputStream;
import java.io.StringReader;
import java.io.StringWriter;
import java.io.Writer;

import fr.opensagres.xdocreport.document.odt.preprocessor.ODTBufferedDocumentContentHandler;
import fr.opensagres.xdocreport.document.odt.preprocessor.ODTStyleContentHandler;
import fr.opensagres.xdocreport.document.preprocessor.sax.BufferedDocument;
import fr.opensagres.xdocreport.document.preprocessor.sax.BufferedDocumentContentHandler;
import fr.opensagres.xdocreport.document.textstyling.IDocumentHandler;
import fr.opensagres.xdocreport.document.textstyling.ITextStylingTransformer;
import fr.opensagres.xdocreport.document.textstyling.html.HTMLTextStylingTransformer;
import static org.junit.Assert.assertThat;

/**
* Check ODT Styling generation by comparing generated result against the expected XML
Expand Down Expand Up @@ -104,7 +100,7 @@ public String formatXML( String unformattedXml )
Transformer serializer = tfactory.newTransformer();

serializer.setOutputProperty( OutputKeys.INDENT, "yes" );
serializer.setOutputProperty( OutputPropertiesFactory.S_KEY_INDENT_AMOUNT, "2" );
serializer.setOutputProperty( "{http:// xml. apache. org/ xalan}indent-amount", "2" );
serializer.setOutputProperty( OutputKeys.STANDALONE, "no" );

Writer out = new StringWriter();
Expand Down
14 changes: 14 additions & 0 deletions document/fr.opensagres.xdocreport.document.tools/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -145,5 +145,19 @@
<artifactId>logback-classic</artifactId>
<version>1.2.13</version>
</dependency>

<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-rt</artifactId>
<version>2.3.7</version>
<type>pom</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>rt</artifactId>
<version>2.3.7</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<version>3.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<source>17</source>
<target>17</target>
</configuration>
</plugin>
<plugin>
Expand Down
12 changes: 8 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,16 @@
<osgi-version-qualifier>${maven.build.timestamp}</osgi-version-qualifier>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.build.timestamp.format>yyyyMMddHHmm</maven.build.timestamp.format>
<maven.compiler.release>17</maven.compiler.release>
</properties>
<build>
<defaultGoal>install</defaultGoal>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
<source>17</source>
<target>17</target>
</configuration>
</plugin>
<plugin>
Expand Down Expand Up @@ -73,7 +74,7 @@
<_snapshot>${osgi-version-qualifier}</_snapshot>
<_nouses>true</_nouses>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Bundle-RequiredExecutionEnvironment>JavaSE-1.6</Bundle-RequiredExecutionEnvironment>
<Bundle-RequiredExecutionEnvironment>JavaSE-17</Bundle-RequiredExecutionEnvironment>
</instructions>
</configuration>
</plugin>
Expand Down Expand Up @@ -177,11 +178,14 @@
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.14</version>
<configuration>
<argLine>--add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.net=ALL-UNNAMED</argLine>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.3.7</version>
<version>5.1.9</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,20 @@
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-rt</artifactId>
<version>2.3.7</version>
<type>pom</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>rt</artifactId>
<version>2.3.7</version>
<scope>test</scope>
</dependency>

</dependencies>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,11 @@
*/
package fr.opensagres.odfdom.converter.pdf.internal.stylable;

import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.Map;

import com.lowagie.text.Chunk;
import com.lowagie.text.Element;
import com.lowagie.text.Font;
import com.lowagie.text.Paragraph;
import com.lowagie.text.pdf.BaseFont;

import fr.opensagres.odfdom.converter.core.utils.ODFUtils;
import fr.opensagres.odfdom.converter.pdf.internal.styles.Style;
import fr.opensagres.odfdom.converter.pdf.internal.styles.StyleBreak;
Expand All @@ -42,6 +37,10 @@
import fr.opensagres.odfdom.converter.pdf.internal.styles.StyleTextProperties;
import fr.opensagres.xdocreport.openpdf.extension.ExtendedParagraph;

import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.Map;

/**
* fixes for paragraph pdf conversion by Leszek Piotrowicz <[email protected]>
*/
Expand Down Expand Up @@ -249,9 +248,9 @@ private void postProcessBookmarks()

Chunk lastChunk = (Chunk) elements.get( elements.size() - 1 );
String localDestination = null;
if ( lastChunk.getAttributes() != null )
if ( lastChunk.getChunkAttributes() != null )
{
localDestination = (String) lastChunk.getAttributes().get( Chunk.LOCALDESTINATION );
localDestination = (String) lastChunk.getChunkAttributes().get( Chunk.LOCALDESTINATION );
}
if ( localDestination != null )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,7 @@
<dependency>
<groupId>com.github.librepdf</groupId>
<artifactId>openpdf</artifactId>
<version>1.3.18</version>
<exclusions>
<exclusion>
<artifactId>bcmail-jdk14</artifactId>
<groupId>org.bouncycastle</groupId>
</exclusion>
<exclusion>
<artifactId>bcprov-jdk14</artifactId>
<groupId>org.bouncycastle</groupId>
</exclusion>
<exclusion>
<artifactId>bctsp-jdk14</artifactId>
<groupId>org.bouncycastle</groupId>
</exclusion>
<exclusion>
<groupId>bouncycastle</groupId>
<artifactId>bcprov-jdk14</artifactId>
</exclusion>
<exclusion>
<groupId>bouncycastle</groupId>
<artifactId>bctsp-jdk14</artifactId>
</exclusion>
<exclusion>
<groupId>bouncycastle</groupId>
<artifactId>bcmail-jdk14</artifactId>
</exclusion>
</exclusions>
<version>2.0.2</version>
</dependency>
<dependency>
<artifactId>bcmail-jdk14</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,38 +184,38 @@ boolean rowSpanAbove( int currRow, int currCol )
}

@Override
public void addCell( Image image )
public PdfPCell addCell( Image image )
{
this.empty = false;
super.addCell( image );
return super.addCell( image );
}

@Override
public void addCell( PdfPCell cell )
public PdfPCell addCell( PdfPCell cell )
{
this.empty = false;
super.addCell( cell );
return super.addCell( cell );
}

@Override
public void addCell( PdfPTable table )
public PdfPCell addCell( PdfPTable table )
{
this.empty = false;
super.addCell( table );
return super.addCell( table );
}

@Override
public void addCell( Phrase phrase )
public PdfPCell addCell( Phrase phrase )
{
this.empty = false;
super.addCell( phrase );
return super.addCell( phrase );
}

@Override
public void addCell( String text )
public PdfPCell addCell( String text )
{
this.empty = false;
super.addCell( text );
return super.addCell( text );
}

public boolean isEmpty()
Expand Down