You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ja...@apache.org on 2014/10/22 02:00:47 UTC

svn commit: r1633490 - in /pdfbox/trunk: examples/src/main/java/org/apache/pdfbox/examples/pdmodel/ pdfbox/src/main/java/org/apache/pdfbox/pdmodel/ pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/ pdfbox/src/main/java/org/apache/pdfbox/pdmodel/in...

Author: jahewson
Date: Wed Oct 22 00:00:46 2014
New Revision: 1633490

URL: http://svn.apache.org/r1633490
Log:
PDFBOX-1329: Move page size constants from PDPage to PDRectangle, and clean up PDPage.

Modified:
    pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/CreateLandscapePDF.java
    pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/UsingTextMatrix.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocument.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPage.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/PDRectangle.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible/PDVisibleSigBuilder.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/LayerUtility.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/Overlay.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/PDFMergerUtility.java
    pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/graphics/image/CCITTFactoryTest.java
    pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/util/PDFCloneUtilityTest.java
    pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/process/reflect/SinglePageValidationProcess.java
    pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PDFToImage.java

Modified: pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/CreateLandscapePDF.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/CreateLandscapePDF.java?rev=1633490&r1=1633489&r2=1633490&view=diff
==============================================================================
--- pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/CreateLandscapePDF.java (original)
+++ pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/CreateLandscapePDF.java Wed Oct 22 00:00:46 2014
@@ -56,8 +56,7 @@ public class CreateLandscapePDF
             doc = new PDDocument();
 
             PDFont font = PDType1Font.HELVETICA;
-            PDPage page = new PDPage();
-            page.setMediaBox(PDPage.PAGE_SIZE_A4);
+            PDPage page = new PDPage(PDRectangle.A4);
             page.setRotation(90);
             doc.addPage(page);
             PDRectangle pageSize = page.findMediaBox();

Modified: pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/UsingTextMatrix.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/UsingTextMatrix.java?rev=1633490&r1=1633489&r2=1633490&view=diff
==============================================================================
--- pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/UsingTextMatrix.java (original)
+++ pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/UsingTextMatrix.java Wed Oct 22 00:00:46 2014
@@ -57,8 +57,7 @@ public class UsingTextMatrix
 
             // Page 1
             PDFont font = PDType1Font.HELVETICA;
-            PDPage page = new PDPage();
-            page.setMediaBox(PDPage.PAGE_SIZE_A4);
+            PDPage page = new PDPage(PDRectangle.A4);
             doc.addPage(page);
             float fontSize = 12.0f;
 
@@ -88,8 +87,7 @@ public class UsingTextMatrix
             contentStream.close();
 
             // Page 2
-            page = new PDPage();
-            page.setMediaBox(PDPage.PAGE_SIZE_A4);
+            page = new PDPage(PDRectangle.A4);
             doc.addPage(page);
             fontSize = 1.0f;
 
@@ -107,8 +105,7 @@ public class UsingTextMatrix
             contentStream.close();
 
             // Page 3
-            page = new PDPage();
-            page.setMediaBox(PDPage.PAGE_SIZE_A4);
+            page = new PDPage(PDRectangle.A4);
             doc.addPage(page);
             fontSize = 1.0f;
 

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocument.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocument.java?rev=1633490&r1=1633489&r2=1633490&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocument.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocument.java Wed Oct 22 00:00:46 2014
@@ -604,7 +604,7 @@ public class PDDocument implements Close
      */
     public PDPage importPage(PDPage page) throws IOException
     {
-        PDPage importedPage = new PDPage(new COSDictionary(page.getCOSDictionary()));
+        PDPage importedPage = new PDPage(new COSDictionary(page.getCOSObject()));
         InputStream is = null;
         OutputStream os = null;
         try

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPage.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPage.java?rev=1633490&r1=1633489&r2=1633490&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPage.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPage.java Wed Oct 22 00:00:46 2014
@@ -47,79 +47,42 @@ import org.apache.pdfbox.pdmodel.interac
 public class PDPage implements COSObjectable
 {
     private static final Log LOG = LogFactory.getLog(PDPage.class);
-    private static final int DEFAULT_USER_SPACE_UNIT_DPI = 72;
-    private static final float MM_TO_UNITS = 1 / (10 * 2.54f) * DEFAULT_USER_SPACE_UNIT_DPI;
 
     // todo: make the constants below an enum
 
-    /**
-     * A page size of LETTER or 8.5x11.
-     */
-    public static final PDRectangle PAGE_SIZE_LETTER = new PDRectangle(8.5f * DEFAULT_USER_SPACE_UNIT_DPI,
-            11f * DEFAULT_USER_SPACE_UNIT_DPI);
-    /**
-     * A page size of A0 Paper.
-     */
-    public static final PDRectangle PAGE_SIZE_A0 = new PDRectangle(841 * MM_TO_UNITS, 1189 * MM_TO_UNITS);
-    /**
-     * A page size of A1 Paper.
-     */
-    public static final PDRectangle PAGE_SIZE_A1 = new PDRectangle(594 * MM_TO_UNITS, 841 * MM_TO_UNITS);
-    /**
-     * A page size of A2 Paper.
-     */
-    public static final PDRectangle PAGE_SIZE_A2 = new PDRectangle(420 * MM_TO_UNITS, 594 * MM_TO_UNITS);
-    /**
-     * A page size of A3 Paper.
-     */
-    public static final PDRectangle PAGE_SIZE_A3 = new PDRectangle(297 * MM_TO_UNITS, 420 * MM_TO_UNITS);
-    /**
-     * A page size of A4 Paper.
-     */
-    public static final PDRectangle PAGE_SIZE_A4 = new PDRectangle(210 * MM_TO_UNITS, 297 * MM_TO_UNITS);
-    /**
-     * A page size of A5 Paper.
-     */
-    public static final PDRectangle PAGE_SIZE_A5 = new PDRectangle(148 * MM_TO_UNITS, 210 * MM_TO_UNITS);
-    /**
-     * A page size of A6 Paper.
-     */
-    public static final PDRectangle PAGE_SIZE_A6 = new PDRectangle(105 * MM_TO_UNITS, 148 * MM_TO_UNITS);
-
     private final COSDictionary page;
     private PDResources pageResources;
-    private PDRectangle mediaBox = null;
+    private PDRectangle mediaBox;
+    private PDPageNode parent;
 
     /**
-     * Creates a new instance of PDPage with a size of 8.5x11.
+     * Creates a new PDPage instance for embedding, with a size of U.S. Letter (8.5 x 11 inches).
      */
     public PDPage()
     {
-        page = new COSDictionary();
-        page.setItem(COSName.TYPE, COSName.PAGE);
-        setMediaBox(PAGE_SIZE_LETTER);
+        this(PDRectangle.LETTER);
     }
 
     /**
-     * Creates a new instance of PDPage.
+     * Creates a new instance of PDPage for embedding.
      * 
-     * @param size The MediaBox or the page.
+     * @param mediaBox The MediaBox of the page.
      */
-    public PDPage(PDRectangle size)
+    public PDPage(PDRectangle mediaBox)
     {
         page = new COSDictionary();
         page.setItem(COSName.TYPE, COSName.PAGE);
-        setMediaBox(size);
+        page.setItem(COSName.MEDIA_BOX, mediaBox);
     }
 
     /**
-     * Creates a new instance of PDPage.
+     * Creates a new instance of PDPage for reading.
      * 
-     * @param pageDic The existing page dictionary.
+     * @param pageDictionary A page dictionary in a PDF document.
      */
-    public PDPage(COSDictionary pageDic)
+    public PDPage(COSDictionary pageDictionary)
     {
-        page = pageDic;
+        page = pageDictionary;
     }
 
     /**
@@ -128,24 +91,14 @@ public class PDPage implements COSObject
      * @return The cos object that matches this Java object.
      */
     @Override
-    public COSBase getCOSObject()
-    {
-        return page;
-    }
-
-    /**
-     * This will get the underlying dictionary that this class acts on.
-     * 
-     * @return The underlying dictionary for this class.
-     */
-    public COSDictionary getCOSDictionary()
+    public COSDictionary getCOSObject()
     {
         return page;
     }
 
     /**
-     * This is the parent page node. The parent is a required element of the page. This will be null until this page is
-     * added to the document.
+     * This is the parent page node. The parent is a required element of the page. This will be null
+     * until this page is added to the document.
      * 
      * @return The parent to this page.
      */
@@ -162,8 +115,6 @@ public class PDPage implements COSObject
         return parent;
     }
 
-    private PDPageNode parent = null;
-
     /**
      * This will set the parent of this page.
      * 
@@ -187,7 +138,6 @@ public class PDPage implements COSObject
      * This will get the date that the content stream was last modified. This may return null.
      * 
      * @return The date the content stream was last modified.
-     * 
      * @throws IOException If there is an error accessing the date information.
      */
     public Calendar getLastModified() throws IOException
@@ -196,8 +146,9 @@ public class PDPage implements COSObject
     }
 
     /**
-     * This will get the resources at this page and not look up the hierarchy. This attribute is inheritable, and
-     * findResources() should probably used. This will return null if no resources are available at this level.
+     * This will get the resources at this page and not look up the hierarchy. This attribute is
+     * inheritable, and findResources() should probably used. This will return null if no resources
+     * are available at this level.
      * 
      * @return The resources at this level in the hierarchy.
      */
@@ -269,11 +220,12 @@ public class PDPage implements COSObject
     }
 
     /**
-     * A rectangle, expressed in default user space units, defining the boundaries of the physical medium on which the
-     * page is intended to be displayed or printed
+     * A rectangle, expressed in default user space units, defining the boundaries of the physical
+     * medium on which the page is intended to be displayed or printed
      * 
-     * This will get the MediaBox at this page and not look up the hierarchy. This attribute is inheritable, and
-     * findMediaBox() should probably used. This will return null if no MediaBox are available at this level.
+     * <p>This will get the MediaBox at this page and not look up the hierarchy. This attribute is
+     * inheritable, and findMediaBox() should probably used. This will return null if no MediaBox
+     * are available at this level.
      * 
      * @return The MediaBox at this level in the hierarchy.
      */
@@ -304,8 +256,8 @@ public class PDPage implements COSObject
         }
         if (retval == null)
         {
-            LOG.debug("Can't find MediaBox, using LETTER as default pagesize!");
-            retval = PDPage.PAGE_SIZE_LETTER;
+            LOG.warn("Can't find MediaBox, will use U.S. Letter");
+            retval = PDRectangle.LETTER;
         }
         return retval;
     }
@@ -313,28 +265,29 @@ public class PDPage implements COSObject
     /**
      * This will set the mediaBox for this page.
      * 
-     * @param mediaBoxValue The new mediaBox for this page.
+     * @param mediaBox The new mediaBox for this page.
      */
-    public void setMediaBox(PDRectangle mediaBoxValue)
+    public void setMediaBox(PDRectangle mediaBox)
     {
-        this.mediaBox = mediaBoxValue;
-        if (mediaBoxValue == null)
+        this.mediaBox = mediaBox;
+        if (mediaBox == null)
         {
             page.removeItem(COSName.MEDIA_BOX);
         }
         else
         {
-            page.setItem(COSName.MEDIA_BOX, mediaBoxValue.getCOSArray());
+            page.setItem(COSName.MEDIA_BOX, mediaBox);
         }
     }
 
     /**
-     * A rectangle, expressed in default user space units, defining the visible region of default user space. When the
-     * page is displayed or printed, its contents are to be clipped (cropped) to this rectangle and then imposed on the
-     * output medium in some implementationdefined manner
+     * A rectangle, expressed in default user space units, defining the visible region of default
+     * user space. When the page is displayed or printed, its contents are to be clipped (cropped)
+     * to this rectangle and then imposed on the output medium in some implementation defined manner
      * 
-     * This will get the CropBox at this page and not look up the hierarchy. This attribute is inheritable, and
-     * findCropBox() should probably used. This will return null if no CropBox is available at this level.
+     * <p>This will get the CropBox at this page and not look up the hierarchy. This attribute is
+     * inheritable, and findCropBox() should probably used. This will return null if no CropBox is
+     * available at this level.
      * 
      * @return The CropBox at this level in the hierarchy.
      */
@@ -393,8 +346,8 @@ public class PDPage implements COSObject
     }
 
     /**
-     * This will search for a crop box in the parent and return null if it is not found. It will NOT default to the
-     * media box if it cannot be found.
+     * This will search for a crop box in the parent and return null if it is not found. It will NOT
+     * default to the media box if it cannot be found.
      * 
      * @param node The node
      */
@@ -427,8 +380,9 @@ public class PDPage implements COSObject
     }
 
     /**
-     * A rectangle, expressed in default user space units, defining the region to which the contents of the page should
-     * be clipped when output in a production environment. The default is the CropBox.
+     * A rectangle, expressed in default user space units, defining the region to which the contents
+     * of the page should be clipped when output in a production environment. The default is the
+     * CropBox.
      * 
      * @return The BleedBox attribute.
      */
@@ -460,13 +414,13 @@ public class PDPage implements COSObject
         }
         else
         {
-            page.setItem(COSName.BLEED_BOX, bleedBox.getCOSArray());
+            page.setItem(COSName.BLEED_BOX, bleedBox);
         }
     }
 
     /**
-     * A rectangle, expressed in default user space units, defining the intended dimensions of the finished page after
-     * trimming. The default is the CropBox.
+     * A rectangle, expressed in default user space units, defining the intended dimensions of the
+     * finished page after trimming. The default is the CropBox.
      * 
      * @return The TrimBox attribute.
      */
@@ -498,13 +452,14 @@ public class PDPage implements COSObject
         }
         else
         {
-            page.setItem(COSName.TRIM_BOX, trimBox.getCOSArray());
+            page.setItem(COSName.TRIM_BOX, trimBox);
         }
     }
 
     /**
-     * A rectangle, expressed in default user space units, defining the extent of the page's meaningful content
-     * (including potential white space) as intended by the page's creator The default isthe CropBox.
+     * A rectangle, expressed in default user space units, defining the extent of the page's
+     * meaningful content (including potential white space) as intended by the page's creator The
+     * default is the CropBox.
      * 
      * @return The ArtBox attribute.
      */
@@ -536,14 +491,13 @@ public class PDPage implements COSObject
         }
         else
         {
-            page.setItem(COSName.ART_BOX, artBox.getCOSArray());
+            page.setItem(COSName.ART_BOX, artBox);
         }
     }
     
     /**
-     * Calculate the adjusted crop box from the cropbox and the mediabox as
-     * required by the PDF spec. Use this instead of {@link #findCropBox()} 
-     * when drawing a page.
+     * Calculate the adjusted crop box from the cropbox and the mediabox as required by the PDF
+     * spec. Use this instead of {@link #findCropBox()} when drawing a page.
      *
      * @return the adjusted crop box.
      */
@@ -596,15 +550,14 @@ public class PDPage implements COSObject
         return adjustedCropBox;
     }
 
-    // todo BoxColorInfo
-    // todo Contents
-
     /**
-     * A value representing the rotation. This will be null if not set at this level The number of degrees by which the
-     * page should be rotated clockwise when displayed or printed. The value must be a multiple of 90.
-     * 
-     * This will get the rotation at this page and not look up the hierarchy. This attribute is inheritable, and
-     * findRotation() should probably used. This will return null if no rotation is available at this level.
+     * A value representing the rotation. This will be null if not set at this level The number of
+     * degrees by which the page should be rotated clockwise when displayed or printed. The value
+     * must be a multiple of 90.
+     * 
+     * <p>This will get the rotation at this page and not look up the hierarchy. This attribute is
+     * inheritable, and findRotation() should probably used. This will return null if no rotation
+     * is available at this level.
      * 
      * @return The rotation at this level in the hierarchy.
      */
@@ -655,11 +608,10 @@ public class PDPage implements COSObject
     }
 
     /**
-     * This will get the contents of the PDF Page, in the case that the contents of the page is an array then then the
-     * entire array of streams will be be wrapped and appear as a single stream.
+     * This will get the contents of the PDF Page, in the case that the contents of the page is an
+     * array then then the entire array of streams will be be wrapped and appear as a single stream.
      * 
      * @return The page content stream.
-     * 
      * @throws IOException If there is an error obtaining the stream.
      */
     public PDStream getContents() throws IOException
@@ -678,8 +630,8 @@ public class PDPage implements COSObject
     }
 
     /**
-     * This will get a list of PDThreadBead objects, which are article threads in the document. This will return an
-     * empty list of there are no thread beads.
+     * This will get a list of PDThreadBead objects, which are article threads in the document.
+     * This will return an empty list of there are no thread beads.
      * 
      * @return A list of article threads on this page.
      */
@@ -717,8 +669,8 @@ public class PDPage implements COSObject
     }
 
     /**
-     * Get the metadata that is part of the document catalog. This will return null if there is no meta data for this
-     * object.
+     * Get the metadata that is part of the document catalog. This will return null if there is
+     * no meta data for this object.
      * 
      * @return The metadata for this object.
      */
@@ -773,7 +725,6 @@ public class PDPage implements COSObject
      * This will return a list of the Annotations for this page.
      * 
      * @return List of the PDAnnotation objects.
-     * 
      * @throws IOException If there is an error while creating the annotations.
      */
     public List<PDAnnotation> getAnnotations() throws IOException
@@ -789,7 +740,6 @@ public class PDPage implements COSObject
         else
         {
             List<PDAnnotation> actuals = new ArrayList<PDAnnotation>();
-
             for (int i = 0; i < annots.size(); i++)
             {
                 COSBase item = annots.getObject(i);
@@ -803,11 +753,11 @@ public class PDPage implements COSObject
     /**
      * This will set the list of annotations.
      * 
-     * @param annots The new list of annotations.
+     * @param annotations The new list of annotations.
      */
-    public void setAnnotations(List<PDAnnotation> annots)
+    public void setAnnotations(List<PDAnnotation> annotations)
     {
-        page.setItem(COSName.ANNOTS, COSArrayList.converterToCOSArray(annots));
+        page.setItem(COSName.ANNOTS, COSArrayList.converterToCOSArray(annotations));
     }
 
     @Override
@@ -819,6 +769,6 @@ public class PDPage implements COSObject
     @Override
     public int hashCode()
     {
-        return this.getCOSDictionary().hashCode();
+        return page.hashCode();
     }
 }

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/PDRectangle.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/PDRectangle.java?rev=1633490&r1=1633489&r2=1633490&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/PDRectangle.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/PDRectangle.java Wed Oct 22 00:00:46 2014
@@ -26,14 +26,43 @@ import org.apache.fontbox.util.BoundingB
 import java.awt.Dimension;
 
 /**
- * This represents a rectangle in a PDF document.
+ * A rectangle in a PDF document.
  *
- * @author <a href="mailto:ben@benlitchfield.com">Ben Litchfield</a>
- * 
+ * @author Ben Litchfield
  */
 public class PDRectangle implements COSObjectable
 {
-    private COSArray rectArray;
+    private static final float POINTS_PER_INCH = 72;
+    private static final float MM_PER_INCH = 1 / (10 * 2.54f) * POINTS_PER_INCH;
+
+    /** A rectangle the size of U.S. Letter, 8.5" x 11". */
+    public static final PDRectangle LETTER = new PDRectangle(8.5f * POINTS_PER_INCH,
+                                                             11f *POINTS_PER_INCH);
+    /**  A rectangle the size of U.S. Legal, 8.5" x 14". */
+    public static final PDRectangle LEGAL = new PDRectangle(8.5f * POINTS_PER_INCH,
+                                                            14f * POINTS_PER_INCH);
+    /**  A rectangle the size of A0 Paper. */
+    public static final PDRectangle A0 = new PDRectangle(841 * MM_PER_INCH, 1189 * MM_PER_INCH);
+
+    /** A rectangle the size of A1 Paper. */
+    public static final PDRectangle A1 = new PDRectangle(594 * MM_PER_INCH, 841 * MM_PER_INCH);
+
+    /**  A rectangle the size of A2 Paper. */
+    public static final PDRectangle A2 = new PDRectangle(420 * MM_PER_INCH, 594 * MM_PER_INCH);
+
+    /** A rectangle the size of A3 Paper.  */
+    public static final PDRectangle A3 = new PDRectangle(297 * MM_PER_INCH, 420 * MM_PER_INCH);
+
+    /**  A rectangle the size of A4 Paper. */
+    public static final PDRectangle A4 = new PDRectangle(210 * MM_PER_INCH, 297 * MM_PER_INCH);
+
+    /** A rectangle the size of A5 Paper. */
+    public static final PDRectangle A5 = new PDRectangle(148 * MM_PER_INCH, 210 * MM_PER_INCH);
+
+    /**  A rectangle the size of A6 Paper. */
+    public static final PDRectangle A6 = new PDRectangle(105 * MM_PER_INCH, 148 * MM_PER_INCH);
+
+    private final COSArray rectArray;
 
     /**
      * Constructor.

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible/PDVisibleSigBuilder.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible/PDVisibleSigBuilder.java?rev=1633490&r1=1633489&r2=1633490&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible/PDVisibleSigBuilder.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible/PDVisibleSigBuilder.java Wed Oct 22 00:00:46 2014
@@ -55,8 +55,8 @@ public class PDVisibleSigBuilder impleme
     @Override
     public void createPage(PDVisibleSignDesigner properties)
     {
-        PDPage page = new PDPage();
-        page.setMediaBox(new PDRectangle(properties.getPageWidth(), properties.getPageHeight()));
+        PDPage page = new PDPage(new PDRectangle(properties.getPageWidth(),
+                                                 properties.getPageHeight()));
         pdfStructure.setPage(page);
         log.info("PDF page has been created");
     }
@@ -326,7 +326,7 @@ public class PDVisibleSigBuilder impleme
                                    PDResources holderFormResources, COSArray procSet)
     {
         innerForm.getResources().getCOSObject().setItem(COSName.PROC_SET, procSet);
-        page.getCOSDictionary().setItem(COSName.PROC_SET, procSet);
+        page.getCOSObject().setItem(COSName.PROC_SET, procSet);
         innerFormResources.getCOSObject().setItem(COSName.PROC_SET, procSet);
         imageFormResources.getCOSObject().setItem(COSName.PROC_SET, procSet);
         holderFormResources.getCOSObject().setItem(COSName.PROC_SET, procSet);

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/LayerUtility.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/LayerUtility.java?rev=1633490&r1=1633489&r2=1633490&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/LayerUtility.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/LayerUtility.java Wed Oct 22 00:00:46 2014
@@ -94,7 +94,7 @@ public class LayerUtility
 
         //Wrap the existing page's content in a save/restore pair (q/Q) to have a controlled
         //environment to add additional content.
-        COSDictionary pageDictionary = page.getCOSDictionary();
+        COSDictionary pageDictionary = page.getCOSObject();
         COSBase contents = pageDictionary.getDictionaryObject(COSName.CONTENTS);
         if (contents instanceof COSStream)
         {
@@ -159,7 +159,7 @@ public class LayerUtility
         form.setResources(formRes);
 
         //Transfer some values from page to form
-        transferDict(page.getCOSDictionary(), form.getCOSStream(), PAGE_TO_FORM_FILTER, true);
+        transferDict(page.getCOSObject(), form.getCOSStream(), PAGE_TO_FORM_FILTER, true);
 
         Matrix matrix = form.getMatrix();
         AffineTransform at = matrix != null ? matrix.createAffineTransform() : new AffineTransform();

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/Overlay.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/Overlay.java?rev=1633490&r1=1633489&r2=1633490&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/Overlay.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/Overlay.java Wed Oct 22 00:00:46 2014
@@ -216,7 +216,7 @@ public class Overlay
     {
         PDDocumentCatalog catalog = doc.getDocumentCatalog();
         PDPage page = (PDPage) catalog.getAllPages().get(0);
-        COSBase contents = page.getCOSDictionary().getDictionaryObject(COSName.CONTENTS);
+        COSBase contents = page.getCOSObject().getDictionaryObject(COSName.CONTENTS);
         PDResources resources = page.findResources();
         if (resources == null)
         {
@@ -234,7 +234,7 @@ public class Overlay
         for (int i=0;i<numberOfPages;i++)
         {
             PDPage page = (PDPage) catalog.getAllPages().get(i);
-            COSBase contents = page.getCOSDictionary().getDictionaryObject(COSName.CONTENTS);
+            COSBase contents = page.getCOSObject().getDictionaryObject(COSName.CONTENTS);
             PDResources resources = page.findResources();
             if (resources == null)
             {
@@ -297,7 +297,7 @@ public class Overlay
         int pageCount = 0;
         for (PDPage page : pages)
         {
-            COSDictionary pageDictionary = page.getCOSDictionary();
+            COSDictionary pageDictionary = page.getCOSObject();
             COSBase contents = pageDictionary.getDictionaryObject(COSName.CONTENTS);
             COSArray contentArray = new COSArray();
             switch (position)

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/PDFMergerUtility.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/PDFMergerUtility.java?rev=1633490&r1=1633489&r2=1633490&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/PDFMergerUtility.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/PDFMergerUtility.java Wed Oct 22 00:00:46 2014
@@ -461,7 +461,7 @@ public class PDFMergerUtility
         while (pageIter.hasNext())
         {
             PDPage page = pageIter.next();
-            PDPage newPage = new PDPage((COSDictionary) cloner.cloneForNewDocument(page.getCOSDictionary()));
+            PDPage newPage = new PDPage((COSDictionary) cloner.cloneForNewDocument(page.getCOSObject()));
             newPage.setCropBox(page.findCropBox());
             newPage.setMediaBox(page.findMediaBox());
             newPage.setRotation(page.findRotation());
@@ -470,7 +470,7 @@ public class PDFMergerUtility
             if (mergeStructTree)
             {
                 updateStructParentEntries(newPage, destParentTreeNextKey);
-                objMapping.put(page.getCOSDictionary(), newPage.getCOSDictionary());
+                objMapping.put(page.getCOSObject(), newPage.getCOSObject());
                 List<PDAnnotation> oldAnnots = page.getAnnotations();
                 List<PDAnnotation> newAnnots = newPage.getAnnotations();
                 for (int i = 0; i < oldAnnots.size(); i++)

Modified: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/graphics/image/CCITTFactoryTest.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/graphics/image/CCITTFactoryTest.java?rev=1633490&r1=1633489&r2=1633490&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/graphics/image/CCITTFactoryTest.java (original)
+++ pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/graphics/image/CCITTFactoryTest.java Wed Oct 22 00:00:46 2014
@@ -28,6 +28,7 @@ import org.apache.pdfbox.io.RandomAccess
 import org.apache.pdfbox.io.RandomAccessFile;
 import org.apache.pdfbox.pdmodel.PDDocument;
 import org.apache.pdfbox.pdmodel.PDPage;
+import org.apache.pdfbox.pdmodel.common.PDRectangle;
 import org.apache.pdfbox.pdmodel.edit.PDPageContentStream;
 import org.apache.pdfbox.pdmodel.graphics.color.PDDeviceGray;
 import static org.apache.pdfbox.pdmodel.graphics.image.ValidateXImage.checkIdent;
@@ -64,7 +65,7 @@ public class CCITTFactoryTest extends Te
         validate(ximage3, 1, 344, 287, "tiff", PDDeviceGray.INSTANCE.getName());
         BufferedImage bim3 = ImageIO.read(new File(tiffG3Path));
         checkIdent(bim3, ximage3.getOpaqueImage());
-        PDPage page = new PDPage(PDPage.PAGE_SIZE_A4);
+        PDPage page = new PDPage(PDRectangle.A4);
         document.addPage(page);
         PDPageContentStream contentStream = new PDPageContentStream(document, page, true, false);
         contentStream.drawXObject(ximage3, 0, 0, ximage3.getWidth(), ximage3.getHeight());
@@ -75,7 +76,7 @@ public class CCITTFactoryTest extends Te
         validate(ximage4, 1, 344, 287, "tiff", PDDeviceGray.INSTANCE.getName());
         BufferedImage bim4 = ImageIO.read(new File(tiffG3Path));
         checkIdent(bim4, ximage4.getOpaqueImage());
-        page = new PDPage(PDPage.PAGE_SIZE_A4);
+        page = new PDPage(PDRectangle.A4);
         document.addPage(page);
         contentStream = new PDPageContentStream(document, page, true, false);
         contentStream.drawXObject(ximage4, 0, 0, ximage4.getWidth(), ximage4.getHeight());
@@ -119,7 +120,7 @@ public class CCITTFactoryTest extends Te
             BufferedImage bim = imageReader.read(pdfPageNum);
             validate(ximage, 1, bim.getWidth(), bim.getHeight(), "tiff", PDDeviceGray.INSTANCE.getName());
             checkIdent(bim, ximage.getOpaqueImage());
-            PDPage page = new PDPage(PDPage.PAGE_SIZE_A4);
+            PDPage page = new PDPage(PDRectangle.A4);
             float fX = ximage.getWidth() / page.getMediaBox().getWidth();
             float fY = ximage.getHeight() / page.getMediaBox().getHeight();
             float factor = Math.max(fX, fY);

Modified: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/util/PDFCloneUtilityTest.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/util/PDFCloneUtilityTest.java?rev=1633490&r1=1633489&r2=1633490&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/util/PDFCloneUtilityTest.java (original)
+++ pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/util/PDFCloneUtilityTest.java Wed Oct 22 00:00:46 2014
@@ -44,7 +44,7 @@ public class PDFCloneUtilityTest extends
         srcDoc.addPage(pdPage);
         new PDPageContentStream(srcDoc, pdPage, true, true).close();
         new PDPageContentStream(srcDoc, pdPage, true, true).close();
-        new PDFCloneUtility(dstDoc).cloneForNewDocument(pdPage.getCOSDictionary());
+        new PDFCloneUtility(dstDoc).cloneForNewDocument(pdPage.getCOSObject());
         srcDoc.close();
         dstDoc.close();
     }

Modified: pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/process/reflect/SinglePageValidationProcess.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/process/reflect/SinglePageValidationProcess.java?rev=1633490&r1=1633489&r2=1633490&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/process/reflect/SinglePageValidationProcess.java (original)
+++ pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/process/reflect/SinglePageValidationProcess.java Wed Oct 22 00:00:46 2014
@@ -98,7 +98,7 @@ public class SinglePageValidationProcess
      */
     protected void validateActions(PreflightContext context, PDPage page) throws ValidationException
     {
-        ContextHelper.validateElement(context, page.getCOSDictionary(), ACTIONS_PROCESS);
+        ContextHelper.validateElement(context, page.getCOSObject(), ACTIONS_PROCESS);
     }
 
     /**
@@ -143,7 +143,7 @@ public class SinglePageValidationProcess
      */
     protected void validateGraphicObjects(PreflightContext context, PDPage page) throws ValidationException
     {
-        COSBase thumbBase = page.getCOSDictionary().getItem(PAGE_DICTIONARY_VALUE_THUMB);
+        COSBase thumbBase = page.getCOSObject().getItem(PAGE_DICTIONARY_VALUE_THUMB);
         if (thumbBase != null)
         {
             try
@@ -229,7 +229,7 @@ public class SinglePageValidationProcess
      */
     protected void validateGroupTransparency(PreflightContext context, PDPage page) throws ValidationException
     {
-        COSBase baseGroup = page.getCOSDictionary().getItem(XOBJECT_DICTIONARY_KEY_GROUP);
+        COSBase baseGroup = page.getCOSObject().getItem(XOBJECT_DICTIONARY_KEY_GROUP);
         COSDictionary groupDictionary = COSUtils.getAsDictionary(baseGroup, context.getDocument().getDocument());
         if (groupDictionary != null)
         {

Modified: pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PDFToImage.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PDFToImage.java?rev=1633490&r1=1633489&r2=1633490&view=diff
==============================================================================
--- pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PDFToImage.java (original)
+++ pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PDFToImage.java Wed Oct 22 00:00:46 2014
@@ -251,7 +251,7 @@ public class PDFToImage
                 if ( cropBoxLowerLeftX!=0 || cropBoxLowerLeftY!=0
                         || cropBoxUpperRightX!=0 || cropBoxUpperRightY!=0 )
                 {
-                    changeCropBoxes(document,
+                    changeCropBox(document,
                             cropBoxLowerLeftX, cropBoxLowerLeftY,
                             cropBoxUpperRightX, cropBoxUpperRightY);
                 }
@@ -323,7 +323,7 @@ public class PDFToImage
         return retval.toString();
     }
 
-    private static void changeCropBoxes(PDDocument document,float a, float b, float c,float d)
+    private static void changeCropBox(PDDocument document, float a, float b, float c, float d)
     {
         List pages = document.getDocumentCatalog().getAllPages();
         for( int i = 0; i < pages.size(); i++ )
@@ -335,7 +335,6 @@ public class PDFToImage
               rectangle.setLowerLeftY(b);
               rectangle.setUpperRightX(c);
               rectangle.setUpperRightY(d);
-              page.setMediaBox(rectangle);
               page.setCropBox(rectangle);
 
         }