pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From msahy...@apache.org
Subject svn commit: r1704111 - in /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form: PDXFAResource.java PlainTextFormatter.java
Date Sun, 20 Sep 2015 09:06:00 GMT
Author: msahyoun
Date: Sun Sep 20 09:06:00 2015
New Revision: 1704111

URL: http://svn.apache.org/viewvc?rev=1704111&view=rev
Log:
PDFBOX-2852: declare constants; avoid temporary variable

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDXFAResource.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PlainTextFormatter.java

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDXFAResource.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDXFAResource.java?rev=1704111&r1=1704110&r2=1704111&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDXFAResource.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDXFAResource.java
Sun Sep 20 09:06:00 2015
@@ -39,6 +39,12 @@ import org.xml.sax.SAXException;
  */
 public final class PDXFAResource implements COSObjectable
 {
+    
+    /**
+     * The default buffer size
+     */
+    private static final int BUFFER_SIZE = 1024;
+    
     private final COSBase xfa;
 
     /**
@@ -89,7 +95,7 @@ public final class PDXFAResource impleme
             // handle the case if the XFA is split into individual parts
             if (this.getCOSObject() instanceof COSArray) 
             {
-                xfaBytes = new byte[1024];
+                xfaBytes = new byte[BUFFER_SIZE];
                 COSArray cosArray = (COSArray) this.getCOSObject();
                 for (int i = 1; i < cosArray.size(); i += 2) 
                 {
@@ -109,7 +115,7 @@ public final class PDXFAResource impleme
             } 
             else if (xfa.getCOSObject() instanceof COSStream) 
             {
-                xfaBytes = new byte[1024];
+                xfaBytes = new byte[BUFFER_SIZE];
                 is = ((COSStream) xfa.getCOSObject()).createInputStream();
                 int nRead;
                 while ((nRead = is.read(xfaBytes, 0, xfaBytes.length)) != -1) 
@@ -146,7 +152,6 @@ public final class PDXFAResource impleme
         DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
         factory.setNamespaceAware(true);
         DocumentBuilder builder = factory.newDocumentBuilder();
-        Document xfaDocument = builder.parse(new ByteArrayInputStream(this.getBytes()));

-        return xfaDocument;
+        return builder.parse(new ByteArrayInputStream(this.getBytes()));
     }
 }

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PlainTextFormatter.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PlainTextFormatter.java?rev=1704111&r1=1704110&r2=1704111&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PlainTextFormatter.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PlainTextFormatter.java
Sun Sep 20 09:06:00 2015
@@ -63,6 +63,11 @@ class PlainTextFormatter
             return TextAlign.LEFT;
         }
     }
+
+    /**
+     * The scaling factor for font units to PDF units
+     */
+    private static final int FONTSCALE = 1000;
     
     private final AppearanceStyle appearanceStyle;
     private final boolean wrapLines;
@@ -186,7 +191,7 @@ class PlainTextFormatter
                     
                     
                     float lineWidth = appearanceStyle.getFont().getStringWidth(paragraph.getText())
*
-                            appearanceStyle.getFontSize() / 1000f;
+                            appearanceStyle.getFontSize() / FONTSCALE;
                     
                     if (lineWidth < width) 
                     {



Mime
View raw message