pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r915570 - in /pdfbox/trunk/src/main/java/org/apache/pdfbox: Overlay.java cos/COSDocument.java cos/COSName.java examples/signature/ShowSignature.java pdfwriter/COSWriter.java pdmodel/PDResources.java pdmodel/common/PDPageLabelRange.java
Date Tue, 23 Feb 2010 22:55:15 GMT
Author: jukka
Date: Tue Feb 23 22:55:15 2010
New Revision: 915570

URL: http://svn.apache.org/viewvc?rev=915570&view=rev
Log:
PDFBOX-626: Reduce the memory impact of the COS object model

More COSName constants

Modified:
    pdfbox/trunk/src/main/java/org/apache/pdfbox/Overlay.java
    pdfbox/trunk/src/main/java/org/apache/pdfbox/cos/COSDocument.java
    pdfbox/trunk/src/main/java/org/apache/pdfbox/cos/COSName.java
    pdfbox/trunk/src/main/java/org/apache/pdfbox/examples/signature/ShowSignature.java
    pdfbox/trunk/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java
    pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/PDResources.java
    pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/common/PDPageLabelRange.java

Modified: pdfbox/trunk/src/main/java/org/apache/pdfbox/Overlay.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/src/main/java/org/apache/pdfbox/Overlay.java?rev=915570&r1=915569&r2=915570&view=diff
==============================================================================
--- pdfbox/trunk/src/main/java/org/apache/pdfbox/Overlay.java (original)
+++ pdfbox/trunk/src/main/java/org/apache/pdfbox/Overlay.java Tue Feb 23 22:55:15 2010
@@ -63,17 +63,19 @@
 public class Overlay
 {
     /**
-     * COSName constant.
+     * @deprecated use the {@link COSName#XOBJECT} constant instead
      */
-    public static final COSName XOBJECT = COSName.getPDFName("XObject");
+    public static final COSName XOBJECT = COSName.XOBJECT;
+
     /**
-     * COSName constant.
+     * @deprecated use the {@link COSName#PROC_SET} constant instead
      */
-    public static final COSName PROC_SET = COSName.getPDFName("ProcSet");
+    public static final COSName PROC_SET = COSName.PROC_SET;
+
     /**
-     * COSName constant.
+     * @deprecated use the {@link COSName#EXT_G_STATE} constant instead
      */
-    public static final COSName EXT_G_STATE = COSName.getPDFName("ExtGState" );
+    public static final COSName EXT_G_STATE = COSName.EXT_G_STATE;
 
     private List layoutPages = new ArrayList(10);
 
@@ -407,10 +409,10 @@
         }
         COSDictionary docResDict = resources.getCOSDictionary();
         COSDictionary layoutResDict = layoutPage.res;
-        mergeArray(PROC_SET, docResDict, layoutResDict);
+        mergeArray(COSName.PROC_SET, docResDict, layoutResDict);
         mergeDictionary(COSName.FONT, docResDict, layoutResDict, layoutPage.objectNameMap);
-        mergeDictionary(XOBJECT, docResDict, layoutResDict, layoutPage.objectNameMap);
-        mergeDictionary(EXT_G_STATE, docResDict, layoutResDict, layoutPage.objectNameMap);
+        mergeDictionary(COSName.XOBJECT, docResDict, layoutResDict, layoutPage.objectNameMap);
+        mergeDictionary(COSName.EXT_G_STATE, docResDict, layoutResDict, layoutPage.objectNameMap);
 
         //we are going to wrap the existing content around some save/restore
         //graphics state, so the result is

Modified: pdfbox/trunk/src/main/java/org/apache/pdfbox/cos/COSDocument.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/src/main/java/org/apache/pdfbox/cos/COSDocument.java?rev=915570&r1=915569&r2=915570&view=diff
==============================================================================
--- pdfbox/trunk/src/main/java/org/apache/pdfbox/cos/COSDocument.java (original)
+++ pdfbox/trunk/src/main/java/org/apache/pdfbox/cos/COSDocument.java Tue Feb 23 22:55:15
2010
@@ -44,8 +44,6 @@
 public class COSDocument extends COSBase
 {
 
-    private static final COSName ENCRYPT = COSName.getPDFName("Encrypt");
-
     /**
      * Log instance.
      */
@@ -265,7 +263,7 @@
         boolean encrypted = false;
         if( trailer != null )
         {
-            encrypted = trailer.getDictionaryObject( ENCRYPT ) != null;
+            encrypted = trailer.getDictionaryObject( COSName.ENCRYPT ) != null;
         }
         return encrypted;
     }
@@ -278,7 +276,7 @@
      */
     public COSDictionary getEncryptionDictionary()
     {
-        return (COSDictionary)trailer.getDictionaryObject( ENCRYPT );
+        return (COSDictionary)trailer.getDictionaryObject( COSName.ENCRYPT );
     }
 
     /**
@@ -289,7 +287,7 @@
      */
     public void setEncryptionDictionary( COSDictionary encDictionary )
     {
-        trailer.setItem( ENCRYPT, encDictionary );
+        trailer.setItem( COSName.ENCRYPT, encDictionary );
     }
 
     /**
@@ -299,7 +297,7 @@
      */
     public COSArray getDocumentID()
     {
-        return (COSArray) getTrailer().getItem(COSName.getPDFName("ID"));
+        return (COSArray) getTrailer().getItem(COSName.ID);
     }
 
     /**
@@ -309,7 +307,7 @@
      */
     public void setDocumentID( COSArray id )
     {
-        getTrailer().setItem(COSName.getPDFName("ID"), id);
+        getTrailer().setItem(COSName.ID, id);
     }
 
     /**

Modified: pdfbox/trunk/src/main/java/org/apache/pdfbox/cos/COSName.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/src/main/java/org/apache/pdfbox/cos/COSName.java?rev=915570&r1=915569&r2=915570&view=diff
==============================================================================
--- pdfbox/trunk/src/main/java/org/apache/pdfbox/cos/COSName.java (original)
+++ pdfbox/trunk/src/main/java/org/apache/pdfbox/cos/COSName.java Tue Feb 23 22:55:15 2010
@@ -253,6 +253,9 @@
     /** "Encrypt" */
     public static final COSName ENCRYPT = new COSName( "Encrypt" );
 
+    /** "ExtGState" */
+    public static final COSName EXT_G_STATE = new COSName( "ExtGState" );
+
     /** "Extends" */
     public static final COSName EXTENDS = new COSName( "Extends" );
 
@@ -496,6 +499,10 @@
     * A common COSName value.
     */
     public static final COSName PREV = new COSName( "Prev" );
+
+    /** "ProcSet" */
+    public static final COSName PROC_SET = new COSName( "ProcSet" );
+
     /**
      * A common COSName value.
      */

Modified: pdfbox/trunk/src/main/java/org/apache/pdfbox/examples/signature/ShowSignature.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/src/main/java/org/apache/pdfbox/examples/signature/ShowSignature.java?rev=915570&r1=915569&r2=915570&view=diff
==============================================================================
--- pdfbox/trunk/src/main/java/org/apache/pdfbox/examples/signature/ShowSignature.java (original)
+++ pdfbox/trunk/src/main/java/org/apache/pdfbox/examples/signature/ShowSignature.java Tue
Feb 23 22:55:15 2010
@@ -84,19 +84,19 @@
 
                 COSDictionary trailer = document.getDocument().getTrailer();
                 COSDictionary root = (COSDictionary)trailer.getDictionaryObject( COSName.ROOT
);
-                COSDictionary acroForm = (COSDictionary)root.getDictionaryObject( COSName.getPDFName(
"AcroForm" ) );
-                COSArray fields = (COSArray)acroForm.getDictionaryObject( COSName.getPDFName(
"Fields" ) );
+                COSDictionary acroForm = (COSDictionary)root.getDictionaryObject( COSName.ACRO_FORM
);
+                COSArray fields = (COSArray)acroForm.getDictionaryObject( COSName.FIELDS
);
                 for( int i=0; i<fields.size(); i++ )
                 {
                     COSDictionary field = (COSDictionary)fields.getObject( i );
                     String type = field.getNameAsString( "FT" );
                     if( "Sig".equals( type ) )
                     {
-                        COSDictionary cert = (COSDictionary)field.getDictionaryObject( COSName.getPDFName(
"V" ) );
+                        COSDictionary cert = (COSDictionary)field.getDictionaryObject( COSName.V
);
                         if( cert != null )
                         {
                             System.out.println( "Certificate found" );
-                            System.out.println( "Name=" + cert.getDictionaryObject( COSName.getPDFName(
"Name" ) ) );
+                            System.out.println( "Name=" + cert.getDictionaryObject( COSName.NAME
) );
                             System.out.println( "Modified=" + cert.getDictionaryObject( COSName.getPDFName(
"M" ) ) );
                             COSName subFilter = (COSName)cert.getDictionaryObject( COSName.getPDFName(
"SubFilter" ) );
                             if( subFilter != null )
@@ -114,7 +114,7 @@
                                 else if( subFilter.getName().equals( "adbe.pkcs7.sha1" )
)
                                 {
                                     COSString certString = (COSString)cert.getDictionaryObject(
-                                        COSName.getPDFName( "Contents" ) );
+                                        COSName.CONTENTS );
                                     byte[] certData = certString.getBytes();
                                     CertificateFactory factory = CertificateFactory.getInstance(
"X.509" );
                                     ByteArrayInputStream certStream = new ByteArrayInputStream(
certData );

Modified: pdfbox/trunk/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java?rev=915570&r1=915569&r2=915570&view=diff
==============================================================================
--- pdfbox/trunk/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java (original)
+++ pdfbox/trunk/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java Tue Feb 23 22:55:15
2010
@@ -472,7 +472,7 @@
         //sort xref, needed only if object keys not regenerated
         Collections.sort(getXRefEntries());
         COSWriterXRefEntry lastEntry = (COSWriterXRefEntry)getXRefEntries().get( getXRefEntries().size()-1);
-        trailer.setInt(COSName.getPDFName("Size"), (int)lastEntry.getKey().getNumber()+1);
+        trailer.setInt(COSName.SIZE, (int)lastEntry.getKey().getNumber()+1);
         trailer.removeItem( COSName.PREV );
         /**
         COSObject catalog = doc.getCatalog();

Modified: pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/PDResources.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/PDResources.java?rev=915570&r1=915569&r2=915570&view=diff
==============================================================================
--- pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/PDResources.java (original)
+++ pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/PDResources.java Tue Feb 23 22:55:15
2010
@@ -247,7 +247,7 @@
      */
     public void setColorSpaces( Map colorspaces )
     {
-        resources.setItem( COSName.getPDFName( "ColorSpace" ), COSDictionaryMap.convert(
colorspaces ) );
+        resources.setItem( COSName.COLORSPACE, COSDictionaryMap.convert( colorspaces ) );
     }
 
     /**
@@ -260,7 +260,7 @@
     public Map getGraphicsStates()
     {
         Map retval = null;
-        COSDictionary states = (COSDictionary)resources.getDictionaryObject( COSName.getPDFName(
"ExtGState" ) );
+        COSDictionary states = (COSDictionary)resources.getDictionaryObject( COSName.EXT_G_STATE
);
 
         if( states != null )
         {
@@ -290,6 +290,6 @@
             PDExtendedGraphicsState state = (PDExtendedGraphicsState)states.get( name );
             dic.setItem( COSName.getPDFName( name ), state.getCOSObject() );
         }
-        resources.setItem( COSName.getPDFName( "ExtGState" ), dic );
+        resources.setItem( COSName.EXT_G_STATE, dic );
     }
 }

Modified: pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/common/PDPageLabelRange.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/common/PDPageLabelRange.java?rev=915570&r1=915569&r2=915570&view=diff
==============================================================================
--- pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/common/PDPageLabelRange.java (original)
+++ pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/common/PDPageLabelRange.java Tue
Feb 23 22:55:15 2010
@@ -37,7 +37,7 @@
 
     // Page label dictonary (PDF32000-1:2008 Section 12.4.2, Table 159)
     private static final COSName KEY_START = COSName.getPDFName("St");
-    private static final COSName KEY_PREFIX = COSName.getPDFName("P");
+    private static final COSName KEY_PREFIX = COSName.P;
     private static final COSName KEY_STYLE = COSName.getPDFName("S");
 
     // Style entry values (PDF32000-1:2008 Section 12.4.2, Table 159)



Mime
View raw message