pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jahew...@apache.org
Subject svn commit: r1633258 [2/2] - in /pdfbox/trunk: examples/src/main/java/org/apache/pdfbox/examples/pdmodel/ examples/src/main/java/org/apache/pdfbox/examples/util/ pdfbox/src/main/java/org/apache/pdfbox/contentstream/ pdfbox/src/main/java/org/apache/pdfb...
Date Tue, 21 Oct 2014 00:13:39 GMT
Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/PDInlineImage.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/PDInlineImage.java?rev=1633258&r1=1633257&r2=1633258&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/PDInlineImage.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/PDInlineImage.java Tue Oct 21 00:13:37 2014
@@ -22,7 +22,6 @@ import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.util.List;
-import java.util.Map;
 
 import org.apache.pdfbox.cos.COSArray;
 import org.apache.pdfbox.cos.COSBase;
@@ -31,6 +30,7 @@ import org.apache.pdfbox.cos.COSName;
 import org.apache.pdfbox.filter.DecodeResult;
 import org.apache.pdfbox.filter.Filter;
 import org.apache.pdfbox.filter.FilterFactory;
+import org.apache.pdfbox.pdmodel.PDResources;
 import org.apache.pdfbox.pdmodel.common.COSArrayList;
 import org.apache.pdfbox.pdmodel.common.PDMemoryStream;
 import org.apache.pdfbox.pdmodel.common.PDStream;
@@ -49,8 +49,8 @@ public final class PDInlineImage impleme
     // image parameters
     private final COSDictionary parameters;
 
-    // color spaces in current resource dictionary
-    private final Map<String, PDColorSpace> colorSpaces;
+    // the current resources, contains named color spaces
+    private final PDResources resources;
 
     // image data
     private final PDStream stream;
@@ -60,13 +60,13 @@ public final class PDInlineImage impleme
      *
      * @param parameters the image parameters
      * @param data the image data
-     * @param colorSpaces the color spaces in the current resources parameters
+     * @param resources the current resources
      */
-    public PDInlineImage(COSDictionary parameters, byte[] data,
-            Map<String, PDColorSpace> colorSpaces) throws IOException
+    public PDInlineImage(COSDictionary parameters, byte[] data, PDResources resources)
+            throws IOException
     {
         this.parameters = parameters;
-        this.colorSpaces = colorSpaces;
+        this.resources = resources;
 
         DecodeResult decodeResult = null;
         List<String> filters = getFilters();
@@ -134,7 +134,7 @@ public final class PDInlineImage impleme
         if (cs != null)
         {
             // TODO: handling of abbreviated color space names belongs here, not in the factory
-            return PDColorSpace.create(cs, colorSpaces, null);
+            return PDColorSpace.create(cs, resources);
         }
         else if (isStencil())
         {

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/optionalcontent/PDOptionalContentGroup.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/optionalcontent/PDOptionalContentGroup.java?rev=1633258&r1=1633257&r2=1633258&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/optionalcontent/PDOptionalContentGroup.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/optionalcontent/PDOptionalContentGroup.java Tue Oct 21 00:13:37 2014
@@ -16,30 +16,22 @@
  */
 package org.apache.pdfbox.pdmodel.graphics.optionalcontent;
 
-import org.apache.pdfbox.cos.COSBase;
 import org.apache.pdfbox.cos.COSDictionary;
 import org.apache.pdfbox.cos.COSName;
-import org.apache.pdfbox.pdmodel.common.COSObjectable;
+import org.apache.pdfbox.pdmodel.documentinterchange.markedcontent.PDPropertyList;
 
 /**
- * This class represents an optional content group (OCG).
- *
- * @since PDF 1.5
- * @version $Revision$
+ * An optional content group (OCG).
  */
-public class PDOptionalContentGroup implements COSObjectable
+public class PDOptionalContentGroup extends PDPropertyList
 {
-
-    private COSDictionary ocg;
-
     /**
      * Creates a new optional content group (OCG).
      * @param name the name of the content group
      */
     public PDOptionalContentGroup(String name)
     {
-        this.ocg = new COSDictionary();
-        this.ocg.setItem(COSName.TYPE, COSName.OCG);
+        this.dict.setItem(COSName.TYPE, COSName.OCG);
         setName(name);
     }
 
@@ -49,18 +41,12 @@ public class PDOptionalContentGroup impl
      */
     public PDOptionalContentGroup(COSDictionary dict)
     {
+        super(dict);
         if (!dict.getItem(COSName.TYPE).equals(COSName.OCG))
         {
             throw new IllegalArgumentException(
                     "Provided dictionary is not of type '" + COSName.OCG + "'");
         }
-        this.ocg = dict;
-    }
-
-    /** {@inheritDoc} */
-    public COSBase getCOSObject()
-    {
-        return this.ocg;
     }
 
     /**
@@ -69,7 +55,7 @@ public class PDOptionalContentGroup impl
      */
     public String getName()
     {
-        return this.ocg.getString(COSName.NAME);
+        return dict.getString(COSName.NAME);
     }
 
     /**
@@ -78,16 +64,14 @@ public class PDOptionalContentGroup impl
      */
     public void setName(String name)
     {
-        this.ocg.setString(COSName.NAME, name);
+        dict.setString(COSName.NAME, name);
     }
 
     //TODO Add support for "Intent" and "Usage"
 
-    /** {@inheritDoc} */
     @Override
     public String toString()
     {
         return super.toString() + " (" + getName() + ")";
     }
-
 }

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/PDAppearanceStream.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/PDAppearanceStream.java?rev=1633258&r1=1633257&r2=1633258&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/PDAppearanceStream.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/PDAppearanceStream.java Tue Oct 21 00:13:37 2014
@@ -130,7 +130,7 @@ public class PDAppearanceStream implemen
         COSDictionary dict = null;
         if( resources != null )
         {
-            dict = resources.getCOSDictionary();
+            dict = resources.getCOSObject();
         }
         stream.setItem( COSName.RESOURCES, dict );
     }

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible/PDFTemplateBuilder.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible/PDFTemplateBuilder.java?rev=1633258&r1=1633257&r2=1633258&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible/PDFTemplateBuilder.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible/PDFTemplateBuilder.java Tue Oct 21 00:13:37 2014
@@ -21,6 +21,7 @@ import java.awt.image.BufferedImage;
 import java.io.IOException;
 
 import org.apache.pdfbox.cos.COSArray;
+import org.apache.pdfbox.cos.COSName;
 import org.apache.pdfbox.pdmodel.PDDocument;
 import org.apache.pdfbox.pdmodel.PDPage;
 import org.apache.pdfbox.pdmodel.PDResources;
@@ -225,8 +226,8 @@ public interface PDFTemplateBuilder
 	 * @throws IOException
 	 */
 	public void injectAppearanceStreams(PDStream holderFormStream, PDStream innterFormStream,
-                                        PDStream imageFormStream, String imageObjectName,
-                                        String imageName, String innerFormName,
+                                        PDStream imageFormStream, COSName imageObjectName,
+                                        COSName imageName, COSName innerFormName,
                                         PDVisibleSignDesigner properties) throws IOException;
 	
 	/**

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible/PDFTemplateCreator.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible/PDFTemplateCreator.java?rev=1633258&r1=1633257&r2=1633258&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible/PDFTemplateCreator.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible/PDFTemplateCreator.java Tue Oct 21 00:13:37 2014
@@ -23,6 +23,7 @@ import java.io.InputStream;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.pdfbox.cos.COSName;
 import org.apache.pdfbox.pdmodel.PDDocument;
 import org.apache.pdfbox.pdmodel.PDPage;
 import org.apache.pdfbox.pdmodel.PDResources;
@@ -139,9 +140,9 @@ public class PDFTemplateCreator
         pdfBuilder.injectProcSetArray(innerForm, page, innerFormResource, imageFormResources,
                 holderFormResources, pdfStructure.getProcSet());
 
-        String imgFormName = pdfStructure.getImageFormName();
-        String imgName = pdfStructure.getImageName();
-        String innerFormName = pdfStructure.getInnerFormName();
+        COSName imgFormName = pdfStructure.getImageFormName();
+        COSName imgName = pdfStructure.getImageName();
+        COSName innerFormName = pdfStructure.getInnerFormName();
 
         // now create Streams of AP
         pdfBuilder.injectAppearanceStreams(holderFormStream, imageFormStream, imageFormStream,

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible/PDFTemplateStructure.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible/PDFTemplateStructure.java?rev=1633258&r1=1633257&r2=1633258&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible/PDFTemplateStructure.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible/PDFTemplateStructure.java Tue Oct 21 00:13:37 2014
@@ -25,6 +25,7 @@ import java.util.List;
 import org.apache.pdfbox.cos.COSArray;
 import org.apache.pdfbox.cos.COSDictionary;
 import org.apache.pdfbox.cos.COSDocument;
+import org.apache.pdfbox.cos.COSName;
 import org.apache.pdfbox.pdfwriter.COSWriter;
 import org.apache.pdfbox.pdmodel.PDDocument;
 import org.apache.pdfbox.pdmodel.PDPage;
@@ -67,9 +68,9 @@ public class PDFTemplateStructure
     private PDStream imageFormStream;
     private PDResources imageFormResources;
     private List<PDFieldTreeNode> acroFormFields;
-    private String innerFormName;
-    private String imageFormName;
-    private String imageName;
+    private COSName innerFormName;
+    private COSName imageFormName;
+    private COSName imageName;
     private COSDocument visualSignature;
     private PDFormXObject imageForm;
     private COSDictionary widgetDictionary;
@@ -418,7 +419,7 @@ public class PDFTemplateStructure
      * Gets name of inner form
      * @return the inner forms's name
      */
-    public String getInnerFormName()
+    public COSName getInnerFormName()
     {
         return innerFormName;
     }
@@ -427,7 +428,7 @@ public class PDFTemplateStructure
      * Sets inner form name
      * @param innerFormName
      */
-    public void setInnerFormName(String innerFormName)
+    public void setInnerFormName(COSName innerFormName)
     {
         this.innerFormName = innerFormName;
     }
@@ -497,7 +498,7 @@ public class PDFTemplateStructure
      * Gets image form name
      * @return the image form's name
      */
-    public String getImageFormName()
+    public COSName getImageFormName()
     {
         return imageFormName;
     }
@@ -506,7 +507,7 @@ public class PDFTemplateStructure
      * Sets image form name
      * @param imageFormName
      */
-    public void setImageFormName(String imageFormName)
+    public void setImageFormName(COSName imageFormName)
     {
         this.imageFormName = imageFormName;
     }
@@ -515,7 +516,7 @@ public class PDFTemplateStructure
      * Gets visible signature image name
      * @return the visible signature's image name
      */
-    public String getImageName()
+    public COSName getImageName()
     {
         return imageName;
     }
@@ -524,7 +525,7 @@ public class PDFTemplateStructure
      * Sets visible signature image name
      * @param imageName
      */
-    public void setImageName(String imageName)
+    public void setImageName(COSName imageName)
     {
         this.imageName = imageName;
     }

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=1633258&r1=1633257&r2=1633258&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 Tue Oct 21 00:13:37 2014
@@ -268,7 +268,7 @@ public class PDVisibleSigBuilder impleme
     public void insertInnerFormToHolerResources(PDFormXObject innerForm,
                                                 PDResources holderFormResources)
     {
-        String name = holderFormResources.addXObject(innerForm, "FRM");
+        COSName name = holderFormResources.add(innerForm, "FRM");
         pdfStructure.setInnerFormName(name);
         log.info("Alerady inserted inner form  inside holder form");
     }
@@ -312,8 +312,8 @@ public class PDVisibleSigBuilder impleme
         // imageForm.getResources().setFonts(fonts);
 
         imageFormResources.getCOSObject().setDirect(true);
-        String imageFormName = innerFormResource.addXObject(imageForm, "n");
-        String imageName = imageFormResources.addXObject(img, "img");
+        COSName imageFormName = innerFormResource.add(imageForm, "n");
+        COSName imageName = imageFormResources.add(img, "img");
         pdfStructure.setImageForm(imageForm);
         pdfStructure.setImageFormName(imageFormName);
         pdfStructure.setImageName(imageName);
@@ -325,27 +325,27 @@ public class PDVisibleSigBuilder impleme
                                    PDResources innerFormResources,  PDResources imageFormResources,
                                    PDResources holderFormResources, COSArray procSet)
     {
-        innerForm.getResources().getCOSDictionary().setItem(COSName.PROC_SET, procSet);
+        innerForm.getResources().getCOSObject().setItem(COSName.PROC_SET, procSet);
         page.getCOSDictionary().setItem(COSName.PROC_SET, procSet);
-        innerFormResources.getCOSDictionary().setItem(COSName.PROC_SET, procSet);
-        imageFormResources.getCOSDictionary().setItem(COSName.PROC_SET, procSet);
-        holderFormResources.getCOSDictionary().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);
         log.info("inserted ProcSet to PDF");
     }
 
     @Override
     public void injectAppearanceStreams(PDStream holderFormStream, PDStream innterFormStream,
-                                        PDStream imageFormStream, String imageObjectName,
-                                        String imageName, String innerFormName,
+                                        PDStream imageFormStream, COSName imageObjectName,
+                                        COSName imageName, COSName innerFormName,
                                         PDVisibleSignDesigner properties) throws IOException
     {
         // 100 means that document width is 100% via the rectangle. if rectangle
         // is 500px, images 100% is 500px.
         // String imgFormComment = "q "+imageWidthSize+ " 0 0 50 0 0 cm /" +
         // imageName + " Do Q\n" + builder.toString();
-        String imgFormComment = "q " + 100 + " 0 0 50 0 0 cm /" + imageName + " Do Q\n";
-        String holderFormComment = "q 1 0 0 1 0 0 cm /" + innerFormName + " Do Q \n";
-        String innerFormComment = "q 1 0 0 1 0 0 cm /" + imageObjectName + " Do Q\n";
+        String imgFormComment = "q " + 100 + " 0 0 50 0 0 cm /" + imageName.getName() + " Do Q\n";
+        String holderFormComment = "q 1 0 0 1 0 0 cm /" + innerFormName.getName() + " Do Q \n";
+        String innerFormComment = "q 1 0 0 1 0 0 cm /" + imageObjectName.getName() + " Do Q\n";
 
         appendRawCommands(pdfStructure.getHolderFormStream().createOutputStream(),
                 holderFormComment);

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDAcroForm.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDAcroForm.java?rev=1633258&r1=1633257&r2=1633258&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDAcroForm.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDAcroForm.java Tue Oct 21 00:13:37 2014
@@ -402,7 +402,7 @@ public final class PDAcroForm implements
         COSDictionary drDict = null;
         if( dr != null )
         {
-            drDict = dr.getCOSDictionary();
+            drDict = dr.getCOSObject();
         }
         acroForm.setItem( COSName.DR, drDict );
     }

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDAppearanceString.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDAppearanceString.java?rev=1633258&r1=1633257&r2=1633258&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDAppearanceString.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDAppearanceString.java Tue Oct 21 00:13:37 2014
@@ -431,12 +431,11 @@ public final class PDAppearanceString
 
             int setFontIndex = tokens.indexOf( Operator.getOperator("Tf"));
             COSName cosFontName = (COSName)tokens.get( setFontIndex-2 );
-            String fontName = cosFontName.getName();
-            retval = (PDFont)streamResources.getFonts().get( fontName );
+            retval = streamResources.getFont( cosFontName );
             if( retval == null )
             {
-                retval = (PDFont)formResources.getFonts().get( fontName );
-                streamResources.addFont(retval, fontName);
+                retval = formResources.getFont( cosFontName );
+                streamResources.put(cosFontName, retval);
             }
         }
         return retval;

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/PDFRenderer.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/PDFRenderer.java?rev=1633258&r1=1633257&r2=1633258&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/PDFRenderer.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/PDFRenderer.java Tue Oct 21 00:13:37 2014
@@ -37,26 +37,13 @@ public class PDFRenderer
     protected final PDDocument document;
     // TODO keep rendering state such as caches here
 
-    private boolean clearResourcesAutomatically;
-
     /**
      * Creates a new PDFRenderer.
      * @param document the document to render
      */
     public PDFRenderer(PDDocument document)
     {
-        this(document, true);
-    }
-
-    /**
-     * Creates a new PDFRenderer.
-     * @param document the document to render
-     * @param clearResourcesAutomatically true to clear cached page resources after rendering
-     */
-    public PDFRenderer(PDDocument document, boolean clearResourcesAutomatically)
-    {
         this.document = document;
-        this.clearResourcesAutomatically = clearResourcesAutomatically;
     }
 
     /**
@@ -226,10 +213,5 @@ public class PDFRenderer
         // TODO: need to make it easy to use a custom PageDrawer and TilingPatternDrawer
         PageDrawer drawer = new PageDrawer(this, page);
         drawer.drawPage(graphics, adjustedCropBox);
-
-        if (clearResourcesAutomatically)
-        {
-            page.clearCache();
-        }
     }
 }

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java?rev=1633258&r1=1633257&r2=1633258&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java Tue Oct 21 00:13:37 2014
@@ -881,7 +881,7 @@ public class PageDrawer extends PDFGraph
     @Override
     public void shadingFill(COSName shadingName) throws IOException
     {
-        PDShading shading = getResources().getShadings().get(shadingName.getName());
+        PDShading shading = getResources().getShading(shadingName);
         Matrix ctm = getGraphicsState().getCurrentTransformationMatrix();
         Paint paint = shading.toPaint(ctm);
 

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=1633258&r1=1633257&r2=1633258&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 Tue Oct 21 00:13:37 2014
@@ -39,7 +39,6 @@ import org.apache.pdfbox.pdmodel.edit.PD
 import org.apache.pdfbox.pdmodel.graphics.form.PDFormXObject;
 import org.apache.pdfbox.pdmodel.graphics.optionalcontent.PDOptionalContentGroup;
 import org.apache.pdfbox.pdmodel.graphics.optionalcontent.PDOptionalContentProperties;
-import org.apache.pdfbox.pdmodel.documentinterchange.markedcontent.PDPropertyList;
 
 /**
  * This class allows to import pages as Form XObjects into a PDF file and use them to create
@@ -242,12 +241,12 @@ public class LayerUtility
         ocprops.addGroup(layer);
 
         PDResources resources = targetPage.findResources();
-        PDPropertyList props = resources.getProperties();
+        /*PDPropertyList props = resources.getProperties();
         if (props == null)
         {
             props = new PDPropertyList();
             resources.setProperties(props);
-        }
+        }*/
 
         //Find first free resource name with the pattern "MC<index>"
         int index = 0;
@@ -256,11 +255,10 @@ public class LayerUtility
         do
         {
             resourceName = COSName.getPDFName("MC" + index);
-            ocg = props.getOptionalContentGroup(resourceName);
             index++;
-        } while (ocg != null);
+        } while (resources.getProperties(resourceName) != null);
         //Put mapping for our new layer/OCG
-        props.putMapping(resourceName, layer);
+        resources.put(resourceName, layer);
 
         PDPageContentStream contentStream = new PDPageContentStream(
                 targetDoc, targetPage, true, !DEBUG);

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=1633258&r1=1633257&r2=1633258&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 Tue Oct 21 00:13:37 2014
@@ -56,8 +56,6 @@ public class Overlay
         FOREGROUND, BACKGROUND
     };
 
-    private static final String XOBJECT_PREFIX = "OL";
-
     private LayoutPage defaultOverlayPage;
     private LayoutPage firstPageOverlayPage;
     private LayoutPage lastPageOverlayPage;
@@ -225,7 +223,7 @@ public class Overlay
             resources = new PDResources();
         }
         return new LayoutPage(page.getMediaBox(), createContentStream(contents),
-                resources.getCOSDictionary());
+                resources.getCOSObject());
     }
     
     private HashMap<Integer,LayoutPage> getLayoutPages(PDDocument doc) throws IOException
@@ -242,7 +240,7 @@ public class Overlay
             {
                 resources = new PDResources();
             }
-            layoutPages.put(i,new LayoutPage(page.getMediaBox(), createContentStream(contents), resources.getCOSDictionary()));
+            layoutPages.put(i,new LayoutPage(page.getMediaBox(), createContentStream(contents), resources.getCOSObject()));
         }
         return layoutPages;
     }
@@ -391,13 +389,13 @@ public class Overlay
                 resources = new PDResources();
                 page.setResources(resources);
             }
-            String xObjectId = createOverlayXObject(page, layoutPage,
+            COSName xObjectId = createOverlayXObject(page, layoutPage,
                     layoutPage.overlayContentStream);
             array.add(createOverlayStream(page, layoutPage, xObjectId));
         }
     }
 
-    private String createOverlayXObject(PDPage page, LayoutPage layoutPage, COSStream contentStream)
+    private COSName createOverlayXObject(PDPage page, LayoutPage layoutPage, COSStream contentStream)
     {
         PDFormXObject xobjForm = new PDFormXObject(new PDStream(contentStream));
         xobjForm.setResources(new PDResources(layoutPage.overlayResources));
@@ -405,10 +403,10 @@ public class Overlay
         xobjForm.setBBox( layoutPage.overlayMediaBox.createRetranslatedRectangle());
         xobjForm.setMatrix(new AffineTransform());
         PDResources resources = page.findResources();
-        return resources.addXObject(xobjForm, XOBJECT_PREFIX);
+        return resources.add(xobjForm, "OL");
     }
 
-    private COSStream createOverlayStream(PDPage page, LayoutPage layoutPage, String xObjectId)
+    private COSStream createOverlayStream(PDPage page, LayoutPage layoutPage, COSName xObjectId)
             throws IOException
     {
         // create a new content stream that executes the XObject content
@@ -417,7 +415,7 @@ public class Overlay
         float hShift = (pageMediaBox.getWidth() - layoutPage.overlayMediaBox.getWidth()) / 2.0f;
         float vShift = (pageMediaBox.getHeight() - layoutPage.overlayMediaBox.getHeight()) / 2.0f;
         return createStream("q\nq " + scale + " 0 0 " + scale + " " + hShift + " " + vShift
-                + " cm /" + xObjectId + " Do Q\nQ\n");
+                + " cm /" + xObjectId.getName() + " Do Q\nQ\n");
     }
 
     private COSStream createStream(String content) throws IOException

Modified: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/graphics/image/ValidateXImage.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/graphics/image/ValidateXImage.java?rev=1633258&r1=1633257&r2=1633258&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/graphics/image/ValidateXImage.java (original)
+++ pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/graphics/image/ValidateXImage.java Tue Oct 21 00:13:37 2014
@@ -25,7 +25,6 @@ import static junit.framework.TestCase.a
 import static junit.framework.TestCase.assertNotNull;
 import static junit.framework.TestCase.assertTrue;
 
-
 import javax.imageio.ImageIO;
 import org.apache.pdfbox.cos.COSName;
 import org.apache.pdfbox.cos.COSStream;
@@ -104,17 +103,27 @@ public class ValidateXImage
         contentStream.close();
         
         // check that the resource map is up-to-date
-        assertEquals(1, document.getPage(0).getResources().getXObjects().size());
+        assertEquals(1, count(document.getPage(0).getResources().getXObjectNames()));
 
         document.save(pdfFile);
         document.close();
 
         document = PDDocument.loadNonSeq(pdfFile, null);
-        assertEquals(1, document.getPage(0).getResources().getXObjects().size());
+        assertEquals(1, count(document.getPage(0).getResources().getXObjectNames()));
         new PDFRenderer(document).renderImage(0);
         document.close();
     }
-    
+
+    private static int count(Iterable<COSName> iterable)
+    {
+        int count = 0;
+        for (COSName name : iterable)
+        {
+            count++;
+        }
+        return count;
+    }
+
     /**
      * Check whether the images are identical.
      *

Modified: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/graphics/optionalcontent/TestOptionalContentGroups.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/graphics/optionalcontent/TestOptionalContentGroups.java?rev=1633258&r1=1633257&r2=1633258&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/graphics/optionalcontent/TestOptionalContentGroups.java (original)
+++ pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/graphics/optionalcontent/TestOptionalContentGroups.java Tue Oct 21 00:13:37 2014
@@ -33,19 +33,14 @@ import org.apache.pdfbox.pdmodel.edit.PD
 import org.apache.pdfbox.pdmodel.font.PDFont;
 import org.apache.pdfbox.pdmodel.font.PDType1Font;
 import org.apache.pdfbox.pdmodel.graphics.optionalcontent.PDOptionalContentProperties.BaseState;
-import org.apache.pdfbox.pdmodel.documentinterchange.markedcontent.PDPropertyList;
 
 /**
  * Tests optional content group functionality (also called layers).
- *
- * @version $Revision$
  */
 public class TestOptionalContentGroups extends TestCase
 {
-
     private File testResultsDir = new File("target/test-output");
 
-    /** {@inheritDoc} */
     @Override
     protected void setUp() throws Exception
     {
@@ -101,16 +96,13 @@ public class TestOptionalContentGroups e
             assertTrue(ocprops.setGroupEnabled("disabled", false));
             assertFalse(ocprops.isGroupEnabled("disabled"));
 
-
-            //Add mapping to page
-            PDPropertyList props = new PDPropertyList();
-            resources.setProperties(props);
+            //Add property lists to page resources
             COSName mc0 = COSName.getPDFName("MC0");
-            props.putMapping(mc0, background);
             COSName mc1 = COSName.getPDFName("MC1");
-            props.putMapping(mc1, enabled);
             COSName mc2 = COSName.getPDFName("MC2");
-            props.putMapping(mc2, disabled);
+            resources.put(mc0, background);
+            resources.put(mc1, enabled);
+            resources.put(mc2, disabled);
 
             //Setup page content stream and paint background/title
             PDPageContentStream contentStream = new PDPageContentStream(doc, page, false, false);
@@ -182,13 +174,12 @@ public class TestOptionalContentGroups e
             assertEquals("1.5", catalog.getVersion());
 
             PDPage page = (PDPage)catalog.getAllPages().get(0);
-            PDPropertyList props = page.findResources().getProperties();
-            assertNotNull(props);
-            PDOptionalContentGroup ocg = props.getOptionalContentGroup(COSName.getPDFName("MC0"));
+            PDOptionalContentGroup ocg = (PDOptionalContentGroup)page.getResources()
+                    .getProperties(COSName.getPDFName("MC0"));
             assertNotNull(ocg);
             assertEquals("background", ocg.getName());
 
-            assertNull(props.getOptionalContentGroup(COSName.getPDFName("inexistent")));
+            assertNull(page.getResources().getProperties(COSName.getPDFName("inexistent")));
 
             PDOptionalContentProperties ocgs = catalog.getOCProperties();
             assertEquals(BaseState.ON, ocgs.getBaseState());

Modified: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/util/TestLayerUtility.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/util/TestLayerUtility.java?rev=1633258&r1=1633257&r2=1633258&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/util/TestLayerUtility.java (original)
+++ pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/util/TestLayerUtility.java Tue Oct 21 00:13:37 2014
@@ -35,7 +35,6 @@ import org.apache.pdfbox.pdmodel.font.PD
 import org.apache.pdfbox.pdmodel.graphics.form.PDFormXObject;
 import org.apache.pdfbox.pdmodel.graphics.optionalcontent.PDOptionalContentGroup;
 import org.apache.pdfbox.pdmodel.graphics.optionalcontent.PDOptionalContentProperties;
-import org.apache.pdfbox.pdmodel.documentinterchange.markedcontent.PDPropertyList;
 
 /**
  * Tests the {@link LayerUtility} class.
@@ -100,9 +99,8 @@ public class TestLayerUtility extends Te
             //assertEquals("1.5", catalog.getVersion());
 
             PDPage page = (PDPage)catalog.getAllPages().get(0);
-            PDPropertyList props = page.findResources().getProperties();
-            assertNotNull(props);
-            PDOptionalContentGroup ocg = props.getOptionalContentGroup(COSName.getPDFName("MC0"));
+            PDOptionalContentGroup ocg = (PDOptionalContentGroup)page.findResources()
+                    .getProperties(COSName.getPDFName("MC0"));
             assertNotNull(ocg);
             assertEquals("overlay", ocg.getName());
 

Modified: pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/content/PreflightStreamEngine.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/content/PreflightStreamEngine.java?rev=1633258&r1=1633257&r2=1633258&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/content/PreflightStreamEngine.java (original)
+++ pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/content/PreflightStreamEngine.java Tue Oct 21 00:13:37 2014
@@ -307,17 +307,13 @@ public abstract class PreflightStreamEng
                 {
                     // The color space is unknown. Try to access the resources dictionary,
                     // the color space can be a reference.
-                    Map<String, PDColorSpace> colorSpaces = this.getResources().getColorSpaces();
-                    if (colorSpaces != null)
+                    PDColorSpace pdCS = this.getResources().getColorSpace(COSName.getPDFName(colorSpace));
+                    if (pdCS != null)
                     {
-                        PDColorSpace pdCS = colorSpaces.get(colorSpace);
-                        if (pdCS != null)
-                        {
-                            cs = ColorSpaces.valueOf(pdCS.getName());
-                            PreflightConfiguration cfg = context.getConfig();
-                            ColorSpaceHelperFactory csFact = cfg.getColorSpaceHelperFact();
-                            csHelper = csFact.getColorSpaceHelper(context, pdCS, ColorSpaceRestriction.ONLY_DEVICE);
-                        }
+                        cs = ColorSpaces.valueOf(pdCS.getName());
+                        PreflightConfiguration cfg = context.getConfig();
+                        ColorSpaceHelperFactory csFact = cfg.getColorSpaceHelperFact();
+                        csHelper = csFact.getColorSpaceHelper(context, pdCS, ColorSpaceRestriction.ONLY_DEVICE);
                     }
                 }
 
@@ -535,17 +531,13 @@ public abstract class PreflightStreamEng
             /*
              * The color space is unknown. Try to access the resources dictionary, the color space can be a reference.
              */
-            Map<String, PDColorSpace> colorSpaces = this.getResources().getColorSpaces();
-            if (colorSpaces != null)
+            PDColorSpace pdCS = this.getResources().getColorSpace(COSName.getPDFName(colorSpaceName));
+            if (pdCS != null)
             {
-                PDColorSpace pdCS = colorSpaces.get(colorSpaceName);
-                if (pdCS != null)
-                {
-                    cs = ColorSpaces.valueOf(pdCS.getName());
-                    PreflightConfiguration cfg = context.getConfig();
-                    ColorSpaceHelperFactory csFact = cfg.getColorSpaceHelperFact();
-                    csHelper = csFact.getColorSpaceHelper(context, pdCS, ColorSpaceRestriction.NO_RESTRICTION);
-                }
+                cs = ColorSpaces.valueOf(pdCS.getName());
+                PreflightConfiguration cfg = context.getConfig();
+                ColorSpaceHelperFactory csFact = cfg.getColorSpaceHelperFact();
+                csHelper = csFact.getColorSpaceHelper(context, pdCS, ColorSpaceRestriction.NO_RESTRICTION);
             }
         }
 

Modified: pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/util/PreflightType3Stream.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/util/PreflightType3Stream.java?rev=1633258&r1=1633257&r2=1633258&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/util/PreflightType3Stream.java (original)
+++ pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/util/PreflightType3Stream.java Tue Oct 21 00:13:37 2014
@@ -91,7 +91,7 @@ public class PreflightType3Stream extend
         {
             image = new PDInlineImage(operator.getImageParameters(),
                                       operator.getImageData(),
-                                      getResources().getColorSpaces());
+                                      getResources());
 
             validImageFilter(operator);
             validImageColorSpace(operator);

Modified: pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/graphic/StandardColorSpaceHelper.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/graphic/StandardColorSpaceHelper.java?rev=1633258&r1=1633257&r2=1633258&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/graphic/StandardColorSpaceHelper.java (original)
+++ pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/graphic/StandardColorSpaceHelper.java Tue Oct 21 00:13:37 2014
@@ -40,6 +40,7 @@ import java.util.Map;
 
 import org.apache.pdfbox.cos.COSArray;
 import org.apache.pdfbox.cos.COSBase;
+import org.apache.pdfbox.cos.COSName;
 import org.apache.pdfbox.pdmodel.PDResources;
 import org.apache.pdfbox.pdmodel.graphics.color.PDColorSpace;
 import org.apache.pdfbox.pdmodel.graphics.color.PDDeviceN;
@@ -416,22 +417,29 @@ public class StandardColorSpaceHelper im
         // get default color space
         PreflightPath vPath = context.getValidationPath();
         PDResources resources = vPath.getClosestPathElement(PDResources.class);
-        if (resources != null && resources.getColorSpaces() != null)
+        if (resources != null)
         {
             PDColorSpace defaultCS = null;
 
-            Map<String, PDColorSpace> colorsSpaces = resources.getColorSpaces();
-            if (pdcs.getName().equals(ColorSpaces.DeviceCMYK.getLabel()))
+            try
             {
-                defaultCS = colorsSpaces.get("DefaultCMYK");
-            }
-            else if (pdcs.getName().equals(ColorSpaces.DeviceRGB.getLabel()))
-            {
-                defaultCS = colorsSpaces.get("DefaultRGB");
+                if (pdcs.getName().equals(ColorSpaces.DeviceCMYK.getLabel()))
+                {
+                    defaultCS = resources.getColorSpace(COSName.DEFAULT_CMYK);
+                }
+                else if (pdcs.getName().equals(ColorSpaces.DeviceRGB.getLabel()))
+                {
+                    defaultCS = resources.getColorSpace(COSName.DEFAULT_RGB);
+                }
+                else if (pdcs.getName().equals(ColorSpaces.DeviceGray.getLabel()))
+                {
+                    defaultCS = resources.getColorSpace(COSName.DEFAULT_GRAY);
+                }
             }
-            else if (pdcs.getName().equals(ColorSpaces.DeviceGray.getLabel()))
+            catch (IOException e)
             {
-                defaultCS = colorsSpaces.get("DefaultGray");
+                context.addValidationError(new ValidationError(ERROR_GRAPHIC_INVALID_COLOR_SPACE,
+                        "Unable to read default color space : " + e.getMessage()));
             }
 
             if (defaultCS != null)

Modified: pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/process/reflect/ResourcesValidationProcess.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/process/reflect/ResourcesValidationProcess.java?rev=1633258&r1=1633257&r2=1633258&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/process/reflect/ResourcesValidationProcess.java (original)
+++ pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/process/reflect/ResourcesValidationProcess.java Tue Oct 21 00:13:37 2014
@@ -26,10 +26,7 @@ import static org.apache.pdfbox.prefligh
 import static org.apache.pdfbox.preflight.PreflightConfiguration.GRAPHIC_PROCESS;
 import static org.apache.pdfbox.preflight.PreflightConfiguration.SHADDING_PATTERN_PROCESS;
 import static org.apache.pdfbox.preflight.PreflightConfiguration.TILING_PATTERN_PROCESS;
-import static org.apache.pdfbox.preflight.PreflightConstants.ERROR_FONTS_DICTIONARY_INVALID;
-import static org.apache.pdfbox.preflight.PreflightConstants.ERROR_FONTS_TRUETYPE_DAMAGED;
 import static org.apache.pdfbox.preflight.PreflightConstants.ERROR_GRAPHIC_INVALID_PATTERN_DEFINITION;
-import static org.apache.pdfbox.preflight.PreflightConstants.ERROR_PDF_PROCESSING_MISSING;
 import static org.apache.pdfbox.preflight.PreflightConstants.TRANPARENCY_DICTIONARY_KEY_EXTGSTATE;
 
 import java.io.IOException;
@@ -45,11 +42,6 @@ import org.apache.pdfbox.cos.COSStream;
 import org.apache.pdfbox.pdmodel.PDResources;
 import org.apache.pdfbox.pdmodel.font.PDFont;
 import org.apache.pdfbox.pdmodel.font.PDFontFactory;
-import org.apache.pdfbox.pdmodel.font.PDMMType1Font;
-import org.apache.pdfbox.pdmodel.font.PDTrueTypeFont;
-import org.apache.pdfbox.pdmodel.font.PDType0Font;
-import org.apache.pdfbox.pdmodel.font.PDType1Font;
-import org.apache.pdfbox.pdmodel.font.PDType3Font;
 import org.apache.pdfbox.pdmodel.graphics.pattern.PDAbstractPattern;
 import org.apache.pdfbox.pdmodel.graphics.pattern.PDTilingPattern;
 import org.apache.pdfbox.pdmodel.graphics.shading.PDShading;
@@ -98,7 +90,7 @@ public class ResourcesValidationProcess 
      */
     protected void validateFonts(PreflightContext context, PDResources resources) throws ValidationException
     {
-        Map<String, PDFont> mapOfFonts = getFonts(resources.getCOSDictionary(), context);
+        Map<String, PDFont> mapOfFonts = getFonts(resources.getCOSObject(), context);
         if (mapOfFonts != null)
         {
             for (Entry<String, PDFont> entry : mapOfFonts.entrySet())
@@ -217,7 +209,7 @@ public class ResourcesValidationProcess 
      */
     protected void validateExtGStates(PreflightContext context, PDResources resources) throws ValidationException
     {
-        COSBase egsEntry = resources.getCOSDictionary().getItem(TRANPARENCY_DICTIONARY_KEY_EXTGSTATE);
+        COSBase egsEntry = resources.getCOSObject().getItem(TRANPARENCY_DICTIONARY_KEY_EXTGSTATE);
         COSDocument cosDocument = context.getDocument().getDocument();
         COSDictionary extGState = COSUtils.getAsDictionary(egsEntry, cosDocument);
         if (egsEntry != null)
@@ -237,13 +229,10 @@ public class ResourcesValidationProcess 
     {
         try
         {
-            Map<String, PDShading> shadingResources = resources.getShadings();
-            if (shadingResources != null)
+            for (COSName name : resources.getShadingNames())
             {
-                for (Entry<String, PDShading> entry : shadingResources.entrySet())
-                {
-                    ContextHelper.validateElement(context, entry.getValue(), SHADDING_PATTERN_PROCESS);
-                }
+                PDShading shading = resources.getShading(name);
+                ContextHelper.validateElement(context, shading, SHADDING_PATTERN_PROCESS);
             }
         }
         catch (IOException e)
@@ -263,15 +252,12 @@ public class ResourcesValidationProcess 
     {
         try
         {
-            Map<String, PDAbstractPattern> patternResources = resources.getPatterns();
-            if (patternResources != null)
+            for (COSName name : resources.getPatternNames())
             {
-                for (Entry<String, PDAbstractPattern> entry : patternResources.entrySet())
+                PDAbstractPattern pattern = resources.getPattern(name);
+                if (pattern instanceof PDTilingPattern)
                 {
-                    if (entry.getValue() instanceof PDTilingPattern)
-                    {
-                        ContextHelper.validateElement(context, entry.getValue(), TILING_PATTERN_PROCESS);
-                    }
+                    ContextHelper.validateElement(context, pattern, TILING_PATTERN_PROCESS);
                 }
             }
         }
@@ -284,7 +270,7 @@ public class ResourcesValidationProcess 
     protected void validateXObjects(PreflightContext context, PDResources resources) throws ValidationException
     {
         COSDocument cosDocument = context.getDocument().getDocument();
-        COSDictionary mapOfXObj = COSUtils.getAsDictionary(resources.getCOSDictionary().getItem(COSName.XOBJECT),
+        COSDictionary mapOfXObj = COSUtils.getAsDictionary(resources.getCOSObject().getItem(COSName.XOBJECT),
                 cosDocument);
         if (mapOfXObj != null)
         {

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=1633258&r1=1633257&r2=1633258&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 Tue Oct 21 00:13:37 2014
@@ -34,7 +34,6 @@ import static org.apache.pdfbox.prefligh
 
 import java.io.IOException;
 import java.util.List;
-import java.util.Map;
 
 import org.apache.pdfbox.cos.COSBase;
 import org.apache.pdfbox.cos.COSDictionary;
@@ -114,17 +113,22 @@ public class SinglePageValidationProcess
         PDResources resources = page.getResources();
         if (resources != null)
         {
-            Map<String, PDColorSpace> colorSpaces = resources.getColorSpaces();
-            if (colorSpaces != null)
+            PreflightConfiguration config = context.getConfig();
+            ColorSpaceHelperFactory colorSpaceFactory = config.getColorSpaceHelperFact();
+            for (COSName name : resources.getColorSpaceNames())
             {
-                PreflightConfiguration config = context.getConfig();
-                ColorSpaceHelperFactory colorSpaceFactory = config.getColorSpaceHelperFact();
-                for (PDColorSpace pdCS : colorSpaces.values())
+                try
                 {
+                    PDColorSpace pdCS = resources.getColorSpace(name);
                     ColorSpaceHelper csHelper = colorSpaceFactory.getColorSpaceHelper(context, pdCS,
                             ColorSpaceRestriction.NO_RESTRICTION);
                     csHelper.validate();
                 }
+                catch (IOException e)
+                {
+                    // fixme: this code was previously in PDResources
+                    // LOG.error("error while creating a colorspace", exception);
+                }
             }
         }
     }

Modified: pdfbox/trunk/tools/src/test/java/org/apache/pdfbox/tools/imageio/TestImageIOUtils.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/tools/src/test/java/org/apache/pdfbox/tools/imageio/TestImageIOUtils.java?rev=1633258&r1=1633257&r2=1633258&view=diff
==============================================================================
--- pdfbox/trunk/tools/src/test/java/org/apache/pdfbox/tools/imageio/TestImageIOUtils.java (original)
+++ pdfbox/trunk/tools/src/test/java/org/apache/pdfbox/tools/imageio/TestImageIOUtils.java Tue Oct 21 00:13:37 2014
@@ -28,7 +28,6 @@ import java.io.IOException;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
-import java.util.Map;
 import java.util.Set;
 import javax.imageio.ImageIO;
 import javax.imageio.ImageReader;
@@ -39,6 +38,7 @@ import junit.framework.TestCase;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.pdfbox.cos.COSName;
 import org.apache.pdfbox.pdmodel.PDDocument;
 import org.apache.pdfbox.pdmodel.PDPage;
 import org.apache.pdfbox.pdmodel.PDResources;
@@ -70,31 +70,27 @@ public class TestImageIOUtils extends Te
         {
             return;
         }
-        Map<String, PDXObject> xobjects = resources.getXObjects();
-        if (xobjects != null)
+        for (COSName name : resources.getXObjectNames())
         {
-            for (String key : xobjects.keySet())
+            PDXObject xobject = resources.getXObject(name);
+            if (xobject instanceof PDImageXObject)
             {
-                PDXObject xobject = xobjects.get(key);
-                if (xobject instanceof PDImageXObject)
+                PDImageXObject imageObject = (PDImageXObject) xobject;
+                String suffix = imageObject.getSuffix();
+                if (suffix != null)
                 {
-                    PDImageXObject imageObject = (PDImageXObject) xobject;
-                    String suffix = imageObject.getSuffix();
-                    if (suffix != null)
+                    if ("jpx".equals(suffix))
                     {
-                        if ("jpx".equals(suffix))
-                        {
-                            suffix = "JPEG2000";
-                        }
-                        boolean writeOK = ImageIOUtil.writeImage(imageObject.getImage(), suffix,
-                                new ByteArrayOutputStream());
-                        assertTrue(writeOK);
+                        suffix = "JPEG2000";
                     }
+                    boolean writeOK = ImageIOUtil.writeImage(imageObject.getImage(), suffix,
+                            new ByteArrayOutputStream());
+                    assertTrue(writeOK);
                 }
-                else if (xobject instanceof PDFormXObject)
-                {
-                    checkSaveResources(((PDFormXObject) xobject).getResources());
-                }
+            }
+            else if (xobject instanceof PDFormXObject)
+            {
+                checkSaveResources(((PDFormXObject) xobject).getResources());
             }
         }
     }



Mime
View raw message