You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ti...@apache.org on 2015/09/26 14:50:38 UTC

svn commit: r1705446 - in /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox: contentstream/ contentstream/operator/ contentstream/operator/graphics/ pdmodel/graphics/ pdmodel/graphics/form/ pdmodel/graphics/state/ rendering/

Author: tilman
Date: Sat Sep 26 12:50:37 2015
New Revision: 1705446

URL: http://svn.apache.org/viewvc?rev=1705446&view=rev
Log:
PDFBOX-2423, PDFBOX-2993: create PDTransparencyGroup that extends PDFormXObject for more code clarity, as done by John Hewson

Added:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/form/PDTransparencyGroup.java   (with props)
Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/PDFStreamEngine.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/DrawObject.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/graphics/DrawObject.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/PDXObject.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/state/PDSoftMask.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/PDFStreamEngine.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/PDFStreamEngine.java?rev=1705446&r1=1705445&r2=1705446&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/PDFStreamEngine.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/PDFStreamEngine.java Sat Sep 26 12:50:37 2015
@@ -51,6 +51,7 @@ import org.apache.pdfbox.pdmodel.graphic
 import org.apache.pdfbox.pdmodel.graphics.color.PDColor;
 import org.apache.pdfbox.pdmodel.graphics.color.PDColorSpace;
 import org.apache.pdfbox.pdmodel.graphics.form.PDFormXObject;
+import org.apache.pdfbox.pdmodel.graphics.form.PDTransparencyGroup;
 import org.apache.pdfbox.pdmodel.graphics.pattern.PDTilingPattern;
 import org.apache.pdfbox.pdmodel.graphics.state.PDGraphicsState;
 import org.apache.pdfbox.pdmodel.graphics.state.PDTextState;
@@ -156,7 +157,7 @@ public abstract class PDFStreamEngine
      * @param form transparency group (form) XObject
      * @throws IOException if the transparency group cannot be processed
      */
-    public void showTransparencyGroup(PDFormXObject form) throws IOException
+    public void showTransparencyGroup(PDTransparencyGroup form) throws IOException
     {
         processTransparencyGroup(form);
     }

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/DrawObject.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/DrawObject.java?rev=1705446&r1=1705445&r2=1705446&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/DrawObject.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/DrawObject.java Sat Sep 26 12:50:37 2015
@@ -20,6 +20,7 @@ import org.apache.pdfbox.cos.COSBase;
 import org.apache.pdfbox.cos.COSName;
 import org.apache.pdfbox.pdmodel.graphics.PDXObject;
 import org.apache.pdfbox.pdmodel.graphics.form.PDFormXObject;
+import org.apache.pdfbox.pdmodel.graphics.form.PDTransparencyGroup;
 import org.apache.pdfbox.text.PDFMarkedContentExtractor;
 
 import java.io.IOException;
@@ -52,9 +53,13 @@ public class DrawObject extends Operator
             ((PDFMarkedContentExtractor) context).xobject(xobject);
         }
 
-        if(xobject instanceof PDFormXObject)
+        if (xobject instanceof PDTransparencyGroup)
         {
-            PDFormXObject form = (PDFormXObject)xobject;
+            context.showTransparencyGroup((PDTransparencyGroup) xobject);
+        }
+        else if (xobject instanceof PDFormXObject)
+        {
+            PDFormXObject form = (PDFormXObject) xobject;
             context.showForm(form);
         }
     }

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/graphics/DrawObject.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/graphics/DrawObject.java?rev=1705446&r1=1705445&r2=1705446&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/graphics/DrawObject.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/graphics/DrawObject.java Sat Sep 26 12:50:37 2015
@@ -24,6 +24,7 @@ import org.apache.pdfbox.cos.COSBase;
 import org.apache.pdfbox.cos.COSName;
 import org.apache.pdfbox.pdmodel.MissingResourceException;
 import org.apache.pdfbox.pdmodel.graphics.form.PDFormXObject;
+import org.apache.pdfbox.pdmodel.graphics.form.PDTransparencyGroup;
 import org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject;
 import org.apache.pdfbox.pdmodel.graphics.PDXObject;
 import org.apache.pdfbox.contentstream.operator.Operator;
@@ -60,18 +61,13 @@ public final class DrawObject extends Gr
             PDImageXObject image = (PDImageXObject)xobject;
             context.drawImage(image);
         }
+        else if (xobject instanceof PDTransparencyGroup)
+        {
+            getContext().showTransparencyGroup((PDTransparencyGroup) xobject);
+        }
         else if (xobject instanceof PDFormXObject)
         {
-            PDFormXObject form = (PDFormXObject) xobject;
-            if (form.getGroup() != null &&
-                COSName.TRANSPARENCY.equals(form.getGroup().getSubType()))
-            {
-                getContext().showTransparencyGroup(form);
-            }
-            else
-            {
-                getContext().showForm(form);
-            }
+            getContext().showForm((PDFormXObject) xobject);
         }
     }
 

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/PDXObject.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/PDXObject.java?rev=1705446&r1=1705445&r2=1705446&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/PDXObject.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/PDXObject.java Sat Sep 26 12:50:37 2015
@@ -1,158 +1,165 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.pdfbox.pdmodel.graphics;
-
-import org.apache.pdfbox.cos.COSBase;
-import org.apache.pdfbox.cos.COSName;
-import org.apache.pdfbox.cos.COSStream;
-import org.apache.pdfbox.pdmodel.PDDocument;
-import org.apache.pdfbox.pdmodel.PDResources;
-import org.apache.pdfbox.pdmodel.ResourceCache;
-import org.apache.pdfbox.pdmodel.common.COSObjectable;
-import org.apache.pdfbox.pdmodel.common.PDStream;
-import org.apache.pdfbox.pdmodel.graphics.form.PDFormXObject;
-import org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject;
-
-import java.io.IOException;
-
-/**
- * An external object, or "XObject".
- *
- * @author Ben Litchfield
- * @author John Hewson
- */
-public class PDXObject implements COSObjectable
-{
-    private final PDStream stream;
-
-    /**
-     * Creates a new XObject instance of the appropriate type for the COS stream.
-     *
-     * @param base The stream which is wrapped by this XObject.
-     * @return A new XObject instance.
-     * @throws java.io.IOException if there is an error creating the XObject.
-     */
-    public static PDXObject createXObject(COSBase base, PDResources resources) throws IOException
-    {
-        if (base == null)
-        {
-            // TODO throw an exception?
-            return null;
-        }
-
-        if (!(base instanceof COSStream))
-        {
-            throw new IOException("Unexpected object type: " + base.getClass().getName());
-        }
-
-        COSStream stream = (COSStream)base;
-        String subtype = stream.getNameAsString(COSName.SUBTYPE);
-
-        if (COSName.IMAGE.getName().equals(subtype))
-        {
-            return new PDImageXObject(new PDStream(stream), resources);
-        }
-        else if (COSName.FORM.getName().equals(subtype))
-        {
-            ResourceCache cache = resources != null ? resources.getResourceCache() : null;
-            return new PDFormXObject(stream, cache);
-        }
-        else if (COSName.PS.getName().equals(subtype))
-        {
-            return new PDPostScriptXObject(stream);
-        }
-        else
-        {
-            throw new IOException("Invalid XObject Subtype: " + subtype);
-        }
-    }
-
-    /**
-     * Creates a new XObject from the given stream and subtype.
-     * @param stream The stream to read.
-     */
-    protected PDXObject(COSStream stream, COSName subtype)
-    {
-        this.stream = new PDStream(stream);
-        // could be used for writing:
-        stream.setName(COSName.TYPE, COSName.XOBJECT.getName());
-        stream.setName(COSName.SUBTYPE, subtype.getName());
-    }
-
-    /**
-     * Creates a new XObject from the given stream and subtype.
-     * @param stream The stream to read.
-     */
-    protected PDXObject(PDStream stream, COSName subtype)
-    {
-        this.stream = stream;
-        // could be used for writing:
-        stream.getStream().setName(COSName.TYPE, COSName.XOBJECT.getName());
-        stream.getStream().setName(COSName.SUBTYPE, subtype.getName());
-    }
-
-    /**
-     * Creates a new XObject of the given subtype for writing.
-     * @param document The document in which to create the XObject.
-     * @param subtype The subtype of the new XObject.
-     */
-    protected PDXObject(PDDocument document, COSName subtype)
-    {
-        stream = new PDStream(document);
-        stream.getStream().setName(COSName.TYPE, COSName.XOBJECT.getName());
-        stream.getStream().setName(COSName.SUBTYPE, subtype.getName());
-    }
-
-    /**
-     * Returns the stream.
-     * {@inheritDoc}
-     */
-    @Override
-    public final COSBase getCOSObject()
-    {
-        return stream.getCOSObject();
-    }
-
-    /**
-     * Returns the stream.
-     * @return The stream for this object.
-     */
-    public final COSStream getCOSStream()
-    {
-        return stream.getStream();
-    }
-
-    /**
-     * Returns the stream.
-     * @return The stream for this object.
-     * @deprecated Use {@link #getStream()} instead.
-     */
-    @Deprecated
-    public final PDStream getPDStream()
-    {
-        return stream;
-    }
-
-    /**
-     * Returns the stream.
-     * @return The stream for this object.
-     */
-    public final PDStream getStream()
-    {
-        return stream;
-    }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.pdfbox.pdmodel.graphics;
+
+import org.apache.pdfbox.cos.COSBase;
+import org.apache.pdfbox.cos.COSDictionary;
+import org.apache.pdfbox.cos.COSName;
+import org.apache.pdfbox.cos.COSStream;
+import org.apache.pdfbox.pdmodel.PDDocument;
+import org.apache.pdfbox.pdmodel.PDResources;
+import org.apache.pdfbox.pdmodel.ResourceCache;
+import org.apache.pdfbox.pdmodel.common.COSObjectable;
+import org.apache.pdfbox.pdmodel.common.PDStream;
+import org.apache.pdfbox.pdmodel.graphics.form.PDFormXObject;
+import org.apache.pdfbox.pdmodel.graphics.form.PDTransparencyGroup;
+import org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject;
+
+import java.io.IOException;
+
+/**
+ * An external object, or "XObject".
+ *
+ * @author Ben Litchfield
+ * @author John Hewson
+ */
+public class PDXObject implements COSObjectable
+{
+    private final PDStream stream;
+
+    /**
+     * Creates a new XObject instance of the appropriate type for the COS stream.
+     *
+     * @param base The stream which is wrapped by this XObject.
+     * @return A new XObject instance.
+     * @throws java.io.IOException if there is an error creating the XObject.
+     */
+    public static PDXObject createXObject(COSBase base, PDResources resources) throws IOException
+    {
+        if (base == null)
+        {
+            // TODO throw an exception?
+            return null;
+        }
+
+        if (!(base instanceof COSStream))
+        {
+            throw new IOException("Unexpected object type: " + base.getClass().getName());
+        }
+
+        COSStream stream = (COSStream)base;
+        String subtype = stream.getNameAsString(COSName.SUBTYPE);
+
+        if (COSName.IMAGE.getName().equals(subtype))
+        {
+            return new PDImageXObject(new PDStream(stream), resources);
+        }
+        else if (COSName.FORM.getName().equals(subtype))
+        {
+            ResourceCache cache = resources != null ? resources.getResourceCache() : null;
+            COSDictionary group = (COSDictionary)stream.getDictionaryObject(COSName.GROUP);
+            if (group != null && COSName.TRANSPARENCY.equals(group.getCOSName(COSName.S)))
+            {
+                return new PDTransparencyGroup(stream, cache);
+            }
+            return new PDFormXObject(stream, cache);
+        }
+        else if (COSName.PS.getName().equals(subtype))
+        {
+            return new PDPostScriptXObject(stream);
+        }
+        else
+        {
+            throw new IOException("Invalid XObject Subtype: " + subtype);
+        }
+    }
+
+    /**
+     * Creates a new XObject from the given stream and subtype.
+     * @param stream The stream to read.
+     */
+    protected PDXObject(COSStream stream, COSName subtype)
+    {
+        this.stream = new PDStream(stream);
+        // could be used for writing:
+        stream.setName(COSName.TYPE, COSName.XOBJECT.getName());
+        stream.setName(COSName.SUBTYPE, subtype.getName());
+    }
+
+    /**
+     * Creates a new XObject from the given stream and subtype.
+     * @param stream The stream to read.
+     */
+    protected PDXObject(PDStream stream, COSName subtype)
+    {
+        this.stream = stream;
+        // could be used for writing:
+        stream.getStream().setName(COSName.TYPE, COSName.XOBJECT.getName());
+        stream.getStream().setName(COSName.SUBTYPE, subtype.getName());
+    }
+
+    /**
+     * Creates a new XObject of the given subtype for writing.
+     * @param document The document in which to create the XObject.
+     * @param subtype The subtype of the new XObject.
+     */
+    protected PDXObject(PDDocument document, COSName subtype)
+    {
+        stream = new PDStream(document);
+        stream.getStream().setName(COSName.TYPE, COSName.XOBJECT.getName());
+        stream.getStream().setName(COSName.SUBTYPE, subtype.getName());
+    }
+
+    /**
+     * Returns the stream.
+     * {@inheritDoc}
+     */
+    @Override
+    public final COSBase getCOSObject()
+    {
+        return stream.getCOSObject();
+    }
+
+    /**
+     * Returns the stream.
+     * @return The stream for this object.
+     */
+    public final COSStream getCOSStream()
+    {
+        return stream.getStream();
+    }
+
+    /**
+     * Returns the stream.
+     * @return The stream for this object.
+     * @deprecated Use {@link #getStream()} instead.
+     */
+    @Deprecated
+    public final PDStream getPDStream()
+    {
+        return stream;
+    }
+
+    /**
+     * Returns the stream.
+     * @return The stream for this object.
+     */
+    public final PDStream getStream()
+    {
+        return stream;
+    }
+}

Added: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/form/PDTransparencyGroup.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/form/PDTransparencyGroup.java?rev=1705446&view=auto
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/form/PDTransparencyGroup.java (added)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/form/PDTransparencyGroup.java Sat Sep 26 12:50:37 2015
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.pdfbox.pdmodel.graphics.form;
+
+import org.apache.pdfbox.cos.COSStream;
+import org.apache.pdfbox.pdmodel.PDDocument;
+import org.apache.pdfbox.pdmodel.ResourceCache;
+import org.apache.pdfbox.pdmodel.common.PDStream;
+
+/**
+ * A transparency group.
+ *
+ * @author John Hewson
+ */
+public class PDTransparencyGroup extends PDFormXObject
+{
+    /**
+     * Creates a Transparency Group for reading.
+     * @param stream The XObject stream
+     */
+    public PDTransparencyGroup(PDStream stream)
+    {
+        super(stream);
+    }
+
+    /**
+     * Creates a Transparency Group for reading.
+     * @param stream The XObject stream
+     */
+    public PDTransparencyGroup(COSStream stream, ResourceCache cache)
+    {
+        super(stream, cache);
+    }    
+
+    /**
+     * Creates a Transparency Group for writing, in the given document.
+     * @param document The current document
+     */
+    public PDTransparencyGroup(PDDocument document)
+    {
+        super(document);
+        // todo: set mandatory fields
+    }
+}

Propchange: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/form/PDTransparencyGroup.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/state/PDSoftMask.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/state/PDSoftMask.java?rev=1705446&r1=1705445&r2=1705446&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/state/PDSoftMask.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/state/PDSoftMask.java Sat Sep 26 12:50:37 2015
@@ -1,151 +1,151 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.pdfbox.pdmodel.graphics.state;
-
-import java.io.IOException;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.pdfbox.cos.COSArray;
-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.common.function.PDFunction;
-import org.apache.pdfbox.pdmodel.graphics.PDXObject;
-import org.apache.pdfbox.pdmodel.graphics.form.PDFormXObject;
-
-/**
- * Soft mask.
- *
- * @author Kühn & Weyh Software, GmbH
- */
-public final class PDSoftMask implements COSObjectable
-{
-    /**
-     * Creates a new soft mask.
-     *
-     * @param dictionary SMask
-     */
-    public static PDSoftMask create(COSBase dictionary)
-    {
-        if (dictionary instanceof COSName)
-        {
-            if (COSName.NONE.equals(dictionary))
-            {
-                return null;
-            }
-            else
-            {
-                LOG.warn("Invalid SMask " + dictionary);
-                return null;
-            }
-        }
-        else if (dictionary instanceof COSDictionary)
-        {
-            return new PDSoftMask((COSDictionary) dictionary);
-        }
-        else
-        {
-            LOG.warn("Invalid SMask " + dictionary);
-            return null;
-        }
-    }
-
-    private static final Log LOG = LogFactory.getLog(PDSoftMask.class);
-
-    private final COSDictionary dictionary;
-    private COSName subType = null;
-    private PDFormXObject group = null;
-    private COSArray backdropColor = null;
-    private PDFunction transferFunction = null;
-
-    /**
-     * Creates a new soft mask.
-     */
-    public PDSoftMask(COSDictionary dictionary)
-    {
-        super();
-        this.dictionary = dictionary;
-    }
-
-    @Override
-    public COSDictionary getCOSObject()
-    {
-        return dictionary;
-    }
-
-    /**
-     * Returns the subtype of the soft mask (Alpha, Luminosity) - S entry
-     */
-    public COSName getSubType()
-    {
-        if (subType == null)
-        {
-            subType = (COSName) getCOSObject().getDictionaryObject(COSName.S);
-        }
-        return subType;
-    }
-
-    /**
-     * Returns the G entry of the soft mask object
-     * 
-     * @return form containing the transparency group
-     * @throws IOException
-     */
-    public PDFormXObject getGroup() throws IOException
-    {
-        if (group == null)
-        {
-            COSBase cosGroup = getCOSObject().getDictionaryObject(COSName.G);
-            if (cosGroup != null)
-            {
-                group = (PDFormXObject) PDXObject
-                        .createXObject(cosGroup, null);
-            }
-        }
-        return group;
-    }
-
-    /**
-     * Returns the backdrop color.
-     */
-    public COSArray getBackdropColor()
-    {
-        if (backdropColor == null)
-        {
-            backdropColor = (COSArray) getCOSObject().getDictionaryObject(COSName.BC);
-        }
-        return backdropColor;
-    }
-
-    /**
-     * Returns the transfer function.
-     */
-    public PDFunction getTransferFunction() throws IOException
-    {
-        if (transferFunction == null)
-        {
-            COSBase cosTF = getCOSObject().getDictionaryObject(COSName.TR);
-            if (cosTF != null)
-            {
-                transferFunction = PDFunction.create(cosTF);
-            }
-        }
-        return transferFunction;
-    }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.pdfbox.pdmodel.graphics.state;
+
+import java.io.IOException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.pdfbox.cos.COSArray;
+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.common.function.PDFunction;
+import org.apache.pdfbox.pdmodel.graphics.PDXObject;
+import org.apache.pdfbox.pdmodel.graphics.form.PDFormXObject;
+import org.apache.pdfbox.pdmodel.graphics.form.PDTransparencyGroup;
+
+/**
+ * Soft mask.
+ *
+ * @author Kühn & Weyh Software, GmbH
+ */
+public final class PDSoftMask implements COSObjectable
+{
+    /**
+     * Creates a new soft mask.
+     *
+     * @param dictionary SMask
+     */
+    public static PDSoftMask create(COSBase dictionary)
+    {
+        if (dictionary instanceof COSName)
+        {
+            if (COSName.NONE.equals(dictionary))
+            {
+                return null;
+            }
+            else
+            {
+                LOG.warn("Invalid SMask " + dictionary);
+                return null;
+            }
+        }
+        else if (dictionary instanceof COSDictionary)
+        {
+            return new PDSoftMask((COSDictionary) dictionary);
+        }
+        else
+        {
+            LOG.warn("Invalid SMask " + dictionary);
+            return null;
+        }
+    }
+
+    private static final Log LOG = LogFactory.getLog(PDSoftMask.class);
+
+    private final COSDictionary dictionary;
+    private COSName subType = null;
+    private PDTransparencyGroup group = null;
+    private COSArray backdropColor = null;
+    private PDFunction transferFunction = null;
+
+    /**
+     * Creates a new soft mask.
+     */
+    public PDSoftMask(COSDictionary dictionary)
+    {
+        super();
+        this.dictionary = dictionary;
+    }
+
+    @Override
+    public COSDictionary getCOSObject()
+    {
+        return dictionary;
+    }
+
+    /**
+     * Returns the subtype of the soft mask (Alpha, Luminosity) - S entry
+     */
+    public COSName getSubType()
+    {
+        if (subType == null)
+        {
+            subType = (COSName) getCOSObject().getDictionaryObject(COSName.S);
+        }
+        return subType;
+    }
+
+    /**
+     * Returns the G entry of the soft mask object
+     * 
+     * @return form containing the transparency group
+     * @throws IOException
+     */
+    public PDFormXObject getGroup() throws IOException
+    {
+        if (group == null)
+        {
+            COSBase cosGroup = getCOSObject().getDictionaryObject(COSName.G);
+            if (cosGroup != null)
+            {
+                group = (PDTransparencyGroup) PDXObject.createXObject(cosGroup, null);
+            }
+        }
+        return group;
+    }
+
+    /**
+     * Returns the backdrop color.
+     */
+    public COSArray getBackdropColor()
+    {
+        if (backdropColor == null)
+        {
+            backdropColor = (COSArray) getCOSObject().getDictionaryObject(COSName.BC);
+        }
+        return backdropColor;
+    }
+
+    /**
+     * Returns the transfer function.
+     */
+    public PDFunction getTransferFunction() throws IOException
+    {
+        if (transferFunction == null)
+        {
+            COSBase cosTF = getCOSObject().getDictionaryObject(COSName.TR);
+            if (cosTF != null)
+            {
+                transferFunction = PDFunction.create(cosTF);
+            }
+        }
+        return transferFunction;
+    }
+}

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=1705446&r1=1705445&r2=1705446&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 Sat Sep 26 12:50:37 2015
@@ -54,6 +54,7 @@ import org.apache.pdfbox.pdmodel.graphic
 import org.apache.pdfbox.pdmodel.graphics.color.PDColorSpace;
 import org.apache.pdfbox.pdmodel.graphics.color.PDPattern;
 import org.apache.pdfbox.pdmodel.graphics.form.PDFormXObject;
+import org.apache.pdfbox.pdmodel.graphics.form.PDTransparencyGroup;
 import org.apache.pdfbox.pdmodel.graphics.image.PDImage;
 import org.apache.pdfbox.pdmodel.graphics.pattern.PDAbstractPattern;
 import org.apache.pdfbox.pdmodel.graphics.pattern.PDShadingPattern;
@@ -844,7 +845,7 @@ public class PageDrawer extends PDFGraph
     }
 
     @Override
-    public void showTransparencyGroup(PDFormXObject form) throws IOException
+    public void showTransparencyGroup(PDTransparencyGroup form) throws IOException
     {
         TransparencyGroup group = new TransparencyGroup(form, false);