Upgrade Apache PDFBox dependency from 1.x to 2.0.3

Project: http://git-wip-us.apache.org/repos/asf/zest-java/repo
Commit: http://git-wip-us.apache.org/repos/asf/zest-java/commit/c5cbb597
Tree: http://git-wip-us.apache.org/repos/asf/zest-java/tree/c5cbb597
Diff: http://git-wip-us.apache.org/repos/asf/zest-java/diff/c5cbb597

Branch: refs/heads/develop
Commit: c5cbb597efb96613abd8bbc04fec5647f85ee82f
Parents: bea5bc7
Author: Paul Merlin <paulmer...@apache.org>
Authored: Sun Sep 18 16:23:18 2016 -0700
Committer: Paul Merlin <paulmer...@apache.org>
Committed: Sun Sep 18 16:23:18 2016 -0700

----------------------------------------------------------------------
 libraries.gradle                                       |  2 +-
 .../java/org/apache/zest/envisage/print/PDFWriter.java | 13 ++++++-------
 2 files changed, 7 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zest-java/blob/c5cbb597/libraries.gradle
----------------------------------------------------------------------
diff --git a/libraries.gradle b/libraries.gradle
index 589924d..ac7a974 100644
--- a/libraries.gradle
+++ b/libraries.gradle
@@ -52,7 +52,7 @@ def mongodbVersion = '3.3.0'
 def mysqlVersion = '6.0.4'
 def orgJsonVersion = '20130213'
 def osgiVersion = '4.2.0' // 4.3.0 Fails to compile! - 5.0.0 exists
-def pdfboxVersion = '1.8.12' // 2.x exists
+def pdfboxVersion = '2.0.3'
 def postgresqlVersion = '9.4.1210'
 def prefuseVersion = '1.0.1'
 def restletVersion = '2.3.7'

http://git-wip-us.apache.org/repos/asf/zest-java/blob/c5cbb597/tools/envisage/src/main/java/org/apache/zest/envisage/print/PDFWriter.java
----------------------------------------------------------------------
diff --git 
a/tools/envisage/src/main/java/org/apache/zest/envisage/print/PDFWriter.java 
b/tools/envisage/src/main/java/org/apache/zest/envisage/print/PDFWriter.java
index d31e6ed..5ad5a68 100644
--- a/tools/envisage/src/main/java/org/apache/zest/envisage/print/PDFWriter.java
+++ b/tools/envisage/src/main/java/org/apache/zest/envisage/print/PDFWriter.java
@@ -35,14 +35,13 @@ import java.util.List;
 import javax.imageio.ImageIO;
 import javax.swing.JFileChooser;
 import javax.swing.filechooser.FileFilter;
-import org.apache.pdfbox.exceptions.COSVisitorException;
 import org.apache.pdfbox.pdmodel.PDDocument;
 import org.apache.pdfbox.pdmodel.PDPage;
+import org.apache.pdfbox.pdmodel.PDPageContentStream;
 import org.apache.pdfbox.pdmodel.common.PDRectangle;
-import org.apache.pdfbox.pdmodel.edit.PDPageContentStream;
 import org.apache.pdfbox.pdmodel.font.PDFont;
 import org.apache.pdfbox.pdmodel.font.PDType1Font;
-import org.apache.pdfbox.pdmodel.graphics.xobject.PDJpeg;
+import org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject;
 import org.apache.zest.api.composite.CompositeDescriptor;
 import org.apache.zest.api.composite.DependencyDescriptor;
 import org.apache.zest.api.composite.ModelDescriptor;
@@ -119,14 +118,14 @@ public class PDFWriter
         {
             writeImpl( file, descriptor, graphDisplays );
         }
-        catch( IOException | COSVisitorException ex )
+        catch( IOException ex )
         {
             ex.printStackTrace();
         }
     }
 
     protected void writeImpl( File file, ApplicationDetailDescriptor 
descriptor, List<GraphDisplay> graphDisplays )
-        throws IOException, COSVisitorException
+        throws IOException
     {
         try
         {
@@ -162,7 +161,7 @@ public class PDFWriter
     private void writeGraphPage( GraphDisplay graphDisplay )
         throws IOException
     {
-        File tFile = File.createTempFile( "envisage", "png" );
+        File tFile = File.createTempFile( "envisage", ".png" );
         graphDisplay.saveImage( new FileOutputStream( tFile ), "png", 1d );
 
         BufferedImage img = ImageIO.read( tFile );
@@ -176,7 +175,7 @@ public class PDFWriter
         page.setMediaBox( pdRect );
         doc.addPage( page );
 
-        PDJpeg xImage = new PDJpeg( doc, img );
+        PDImageXObject xImage = PDImageXObject.createFromFileByExtension( 
tFile, doc );
 
         PDPageContentStream contentStream = new PDPageContentStream( doc, page 
);
         contentStream.drawImage( xImage, ( pdRect.getWidth() - w ) / 2, ( 
pdRect.getHeight() - h ) / 2 );

Reply via email to