opensagres / xdocreport

XDocReport means XML Document reporting. It's Java API to merge XML document created with MS Office (docx) or OpenOffice (odt), LibreOffice (odt) with a Java model to generate report and convert it if you need to another format (PDF, XHTML...).
https://github.com/opensagres/xdocreport
1.22k stars 372 forks source link

Update to OpenPDF 2.0.0. #636

Open andreasrosdal opened 7 months ago

andreasrosdal commented 7 months ago

Update to OpenPDF 2.0.0:

https://github.com/opensagres/xdocreport/issues/635 https://github.com/LibrePDF/OpenPDF/releases/tag/2.0.0

Requires Java 17 or later.

henricook commented 7 months ago

Thank you for this @andreasrosdal - it was simple like you said 😂

Misconfigured search in my IDE meant that I couldn't find the dependency so had been scratching my head for ages

Rapster commented 7 months ago

@andreasrosdal There are two files that need to be updated after openpdf upgrade. Here is a preview:

Subject: [PATCH] fix compil
---
Index: thirdparties-extension/fr.opensagres.odfdom.converter.pdf.openpdf/src/main/java/fr/opensagres/odfdom/converter/pdf/internal/stylable/StylableParagraph.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/thirdparties-extension/fr.opensagres.odfdom.converter.pdf.openpdf/src/main/java/fr/opensagres/odfdom/converter/pdf/internal/stylable/StylableParagraph.java b/thirdparties-extension/fr.opensagres.odfdom.converter.pdf.openpdf/src/main/java/fr/opensagres/odfdom/converter/pdf/internal/stylable/StylableParagraph.java
--- a/thirdparties-extension/fr.opensagres.odfdom.converter.pdf.openpdf/src/main/java/fr/opensagres/odfdom/converter/pdf/internal/stylable/StylableParagraph.java   (revision 56be6b35b1439868d3ddf570202ec4cfb0b1e374)
+++ b/thirdparties-extension/fr.opensagres.odfdom.converter.pdf.openpdf/src/main/java/fr/opensagres/odfdom/converter/pdf/internal/stylable/StylableParagraph.java   (revision abc91269f1ce3249ea7d3a20e19c7686931ba493)
@@ -249,9 +249,9 @@

             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 )
             {
Index: thirdparties-extension/fr.opensagres.xdocreport.openpdf.extension/src/main/java/fr/opensagres/xdocreport/openpdf/extension/ExtendedPdfPTable.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/thirdparties-extension/fr.opensagres.xdocreport.openpdf.extension/src/main/java/fr/opensagres/xdocreport/openpdf/extension/ExtendedPdfPTable.java b/thirdparties-extension/fr.opensagres.xdocreport.openpdf.extension/src/main/java/fr/opensagres/xdocreport/openpdf/extension/ExtendedPdfPTable.java
--- a/thirdparties-extension/fr.opensagres.xdocreport.openpdf.extension/src/main/java/fr/opensagres/xdocreport/openpdf/extension/ExtendedPdfPTable.java (revision 56be6b35b1439868d3ddf570202ec4cfb0b1e374)
+++ b/thirdparties-extension/fr.opensagres.xdocreport.openpdf.extension/src/main/java/fr/opensagres/xdocreport/openpdf/extension/ExtendedPdfPTable.java (revision abc91269f1ce3249ea7d3a20e19c7686931ba493)
@@ -184,38 +184,38 @@
     }

     @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()
Rapster commented 7 months ago

As of now, xdocreport requires java 1.7 and openpdf requires java 17. Is there any reason (dependencies for instance?) to stay on java 1.7 for now @opensagres ?

angelozerr commented 7 months ago

@andreasrosdal There are two files that need to be updated after openpdf upgrade. Here is a preview:

could you add you change in this PR please.

angelozerr commented 7 months ago

As of now, xdocreport requires java 1.7 and openpdf requires java 17. Is there any reason (dependencies for instance?) to stay on java 1.7 for now https://github.com/opensagres ?

The main idea is consume XDocReport with any old Java version. I think it is very shame to upgrade to java 17 if XDocReport doesn't use it. If we could consume openpdf without upgrading to Java 17 it should be very nice.

andreasrosdal commented 7 months ago

I hope the maintainers of xdocreport can take over this.