pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1801880 - in /pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox: pdfparser/PDFXRefStream.java pdfwriter/COSWriter.java
Date Thu, 13 Jul 2017 20:12:17 GMT
Author: tilman
Date: Thu Jul 13 20:12:17 2017
New Revision: 1801880

URL: http://svn.apache.org/viewvc?rev=1801880&view=rev
Log:
PDFBOX-3868: avoid memory hungry COSStream constructor

Modified:
    pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/PDFXRefStream.java
    pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java

Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/PDFXRefStream.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/PDFXRefStream.java?rev=1801880&r1=1801879&r2=1801880&view=diff
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/PDFXRefStream.java
(original)
+++ pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/PDFXRefStream.java
Thu Jul 13 20:12:17 2017
@@ -29,6 +29,7 @@ import java.util.TreeSet;
 import org.apache.pdfbox.cos.COSArray;
 import org.apache.pdfbox.cos.COSBase;
 import org.apache.pdfbox.cos.COSDictionary;
+import org.apache.pdfbox.cos.COSDocument;
 import org.apache.pdfbox.cos.COSInteger;
 import org.apache.pdfbox.cos.COSName;
 import org.apache.pdfbox.cos.COSObject;
@@ -57,13 +58,28 @@ public class PDFXRefStream implements PD
 
     /**
      * Create a fresh XRef stream like for a fresh file or an incremental update.
+     * 
+     * @deprecated use {@link #PDFXRefStream(org.apache.pdfbox.cos.COSDocument)}
      */
+    @Deprecated
     public PDFXRefStream()
     {
         this.stream = new COSStream();
         streamData = new TreeMap<Long, Object>();
         objectNumbers = new TreeSet<Long>();
     }
+
+    /**
+     * Create a fresh XRef stream like for a fresh file or an incremental update.
+     * 
+     * @param cosDocument
+     */
+    public PDFXRefStream(COSDocument cosDocument)
+    {
+        stream = cosDocument.createCOSStream();
+        streamData = new TreeMap<Long, Object>();
+        objectNumbers = new TreeSet<Long>();
+    }
 
     /**
      * Returns the stream of the XRef.

Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java?rev=1801880&r1=1801879&r2=1801880&view=diff
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java (original)
+++ pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java Thu
Jul 13 20:12:17 2017
@@ -593,7 +593,7 @@ public class COSWriter implements ICOSVi
             // with data available here
 
             // create a new XRefStrema object
-            PDFXRefStream pdfxRefStream = new PDFXRefStream();
+            PDFXRefStream pdfxRefStream = new PDFXRefStream(doc);
 
             // add all entries from the incremental update.
             List<COSWriterXRefEntry> xRefEntries2 = getXRefEntries();



Mime
View raw message