You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ti...@apache.org on 2016/02/19 23:42:00 UTC

svn commit: r1731305 - /pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDocument.java

Author: tilman
Date: Fri Feb 19 22:42:00 2016
New Revision: 1731305

URL: http://svn.apache.org/viewvc?rev=1731305&view=rev
Log:
PDFBOX-3241: return original header string

Modified:
    pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDocument.java

Modified: pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDocument.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDocument.java?rev=1731305&r1=1731304&r2=1731305&view=diff
==============================================================================
--- pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDocument.java (original)
+++ pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDocument.java Fri Feb 19 22:42:00 2016
@@ -53,6 +53,8 @@ public class COSDocument extends COSBase
 
     private float version = 1.4f;
 
+    private String originalHeaderString = null;
+
     /**
      * Maps ObjectKeys to a COSObject. Note that references to these objects
      * are also stored in COSDictionary objects that map a name to a specific object.
@@ -87,7 +89,7 @@ public class COSDocument extends COSBase
 
     private boolean warnMissingClose = true;
     
-    /** signal that document is already decrypted, e.g. with {@link NonSequentialPDFParser} */
+    /** signal that document is already decrypted, e.g. with {@link org.apache.pdfbox.pdfparser.NonSequentialPDFParser} */
     private boolean isDecrypted = false;
     
     private long startXref;
@@ -334,7 +336,7 @@ public class COSDocument extends COSBase
     }
 
     /**
-     * This will set the version of this PDF document.
+     * This will set the version of this PDF document and update the header string.
      *
      * @param versionValue The version of the PDF document.
      */
@@ -653,7 +655,8 @@ public class COSDocument extends COSBase
     }
 
     /**
-     * @return Returns the headerString.
+     * @return Returns the current headerString. (It may have been updated by calls to 
+     * {@link #setVersion(float) })
      */
     public String getHeaderString()
     {
@@ -665,6 +668,21 @@ public class COSDocument extends COSBase
     public void setHeaderString(String header)
     {
         headerString = header;
+        if (originalHeaderString != null)
+        {
+            originalHeaderString = header;
+        }
+    }
+
+    /**
+     * Get the original headerString from the PDF file. Unlike {@link #getHeaderString()}, the
+     * value is not changed by files that have another header value in the document catalog.
+     *
+     * @return the original header string.
+     */
+    public String getOriginalHeaderString()
+    {
+        return originalHeaderString;
     }
 
     /**