pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1783535 - /pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/fontencodingpane/Type3Font.java
Date Sat, 18 Feb 2017 13:20:42 GMT
Author: tilman
Date: Sat Feb 18 13:20:42 2017
New Revision: 1783535

URL: http://svn.apache.org/viewvc?rev=1783535&view=rev
Log:
PDFBOX-2941: avoid PDDocument leak

Modified:
    pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/fontencodingpane/Type3Font.java

Modified: pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/fontencodingpane/Type3Font.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/fontencodingpane/Type3Font.java?rev=1783535&r1=1783534&r2=1783535&view=diff
==============================================================================
--- pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/fontencodingpane/Type3Font.java
(original)
+++ pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/fontencodingpane/Type3Font.java
Sat Feb 18 13:20:42 2017
@@ -142,31 +142,36 @@ class Type3Font extends FontPane
         }
         PDPage page = new PDPage(new PDRectangle(fontBBox.getWidth() * scale, fontBBox.getHeight()
* scale));
         page.setResources(resources);
-        PDPageContentStream cs = new PDPageContentStream(doc, page);
-        cs.transform(Matrix.getTranslateInstance(-fontBBox.getLowerLeftX(), -fontBBox.getLowerLeftY()));
         try
         {
-            AffineTransform at = font.getFontMatrix().createAffineTransform();
-            if (!at.isIdentity())
+            PDPageContentStream cs = new PDPageContentStream(doc, page);
+            cs.transform(Matrix.getTranslateInstance(-fontBBox.getLowerLeftX(), -fontBBox.getLowerLeftY()));
+            try
             {
-                at.invert();
-                cs.transform(new Matrix(at));
+                AffineTransform at = font.getFontMatrix().createAffineTransform();
+                if (!at.isIdentity())
+                {
+                    at.invert();
+                    cs.transform(new Matrix(at));
+                }
             }
+            catch (NoninvertibleTransformException ex)
+            {
+                // "shouldn't happen"
+            }
+            cs.beginText();
+            cs.setFont(font, scale);
+            //TODO support type3 font encoding in PDType3Font.encode
+            cs.appendRawCommands(String.format("<%02X> Tj\n", index).getBytes(Charsets.ISO_8859_1));
+            cs.endText();
+            cs.close();
+            doc.addPage(page);
+            return new PDFRenderer(doc).renderImage(0);
         }
-        catch (NoninvertibleTransformException ex)
+        finally
         {
-            // "shouldn't happen"
+            doc.close();
         }
-        cs.beginText();
-        cs.setFont(font, scale);
-        //TODO support type3 font encoding in PDType3Font.encode
-        cs.appendRawCommands(String.format("<%02X> Tj\n", index).getBytes(Charsets.ISO_8859_1));
-        cs.endText();
-        cs.close();
-        doc.addPage(page);
-        BufferedImage bim = new PDFRenderer(doc).renderImage(0);
-        doc.close();
-        return bim;
     }
 
     private String getEncodingName(PDSimpleFont font)



Mime
View raw message