aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/pdfbox/util/operator/pagedrawer
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/pdfbox/util/operator/pagedrawer')
-rw-r--r--src/main/java/org/pdfbox/util/operator/pagedrawer/AppendRectangleToPath.java77
-rw-r--r--src/main/java/org/pdfbox/util/operator/pagedrawer/BeginInlineImage.java114
-rw-r--r--src/main/java/org/pdfbox/util/operator/pagedrawer/ClosePath.java59
-rw-r--r--src/main/java/org/pdfbox/util/operator/pagedrawer/CurveTo.java73
-rw-r--r--src/main/java/org/pdfbox/util/operator/pagedrawer/CurveToReplicateFinalPoint.java69
-rw-r--r--src/main/java/org/pdfbox/util/operator/pagedrawer/CurveToReplicateInitialPoint.java76
-rw-r--r--src/main/java/org/pdfbox/util/operator/pagedrawer/FillEvenOddRule.java71
-rw-r--r--src/main/java/org/pdfbox/util/operator/pagedrawer/FillNonZeroRule.java71
-rw-r--r--src/main/java/org/pdfbox/util/operator/pagedrawer/Invoke.java180
-rw-r--r--src/main/java/org/pdfbox/util/operator/pagedrawer/LineTo.java65
-rw-r--r--src/main/java/org/pdfbox/util/operator/pagedrawer/MoveTo.java68
-rw-r--r--src/main/java/org/pdfbox/util/operator/pagedrawer/SetLineWidth.java65
-rw-r--r--src/main/java/org/pdfbox/util/operator/pagedrawer/SetNonStrokingCMYKColor.java64
-rw-r--r--src/main/java/org/pdfbox/util/operator/pagedrawer/SetNonStrokingColorSpace.java71
-rw-r--r--src/main/java/org/pdfbox/util/operator/pagedrawer/SetNonStrokingRGBColor.java65
-rw-r--r--src/main/java/org/pdfbox/util/operator/pagedrawer/SetStrokingCMYKColor.java64
-rw-r--r--src/main/java/org/pdfbox/util/operator/pagedrawer/SetStrokingColorSpace.java70
-rw-r--r--src/main/java/org/pdfbox/util/operator/pagedrawer/SetStrokingRGBColor.java65
-rw-r--r--src/main/java/org/pdfbox/util/operator/pagedrawer/StrokePath.java73
-rw-r--r--src/main/java/org/pdfbox/util/operator/pagedrawer/package.html9
20 files changed, 1469 insertions, 0 deletions
diff --git a/src/main/java/org/pdfbox/util/operator/pagedrawer/AppendRectangleToPath.java b/src/main/java/org/pdfbox/util/operator/pagedrawer/AppendRectangleToPath.java
new file mode 100644
index 0000000..7d2d49f
--- /dev/null
+++ b/src/main/java/org/pdfbox/util/operator/pagedrawer/AppendRectangleToPath.java
@@ -0,0 +1,77 @@
+/**
+ * Copyright (c) 2005, www.pdfbox.org
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of pdfbox; nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * http://www.pdfbox.org
+ *
+ */
+package org.pdfbox.util.operator.pagedrawer;
+
+import java.awt.geom.Rectangle2D;
+import java.util.List;
+
+import org.pdfbox.cos.COSNumber;
+import org.pdfbox.pdfviewer.PageDrawer;
+import org.pdfbox.util.PDFOperator;
+import org.pdfbox.util.operator.OperatorProcessor;
+
+/**
+ * Implementation of content stream operator for page drawer.
+ *
+ * @author Ben Litchfield (ben@benlitchfield.com)
+ * @version $Revision: 1.1 $
+ */
+public class AppendRectangleToPath extends OperatorProcessor
+{
+
+
+ /**
+ * process : re : append rectangle to path.
+ * @param operator The operator that is being executed.
+ * @param arguments List
+ */
+ public void process(PDFOperator operator, List arguments)
+ {
+ PageDrawer drawer = (PageDrawer)context;
+
+ COSNumber x = (COSNumber)arguments.get( 0 );
+ COSNumber y = (COSNumber)arguments.get( 1 );
+ COSNumber w = (COSNumber)arguments.get( 2 );
+ COSNumber h = (COSNumber)arguments.get( 3 );
+ Rectangle2D rect = new Rectangle2D.Double(
+ x.doubleValue(),
+ drawer.fixY( x.doubleValue(), y.doubleValue())-h.doubleValue(),
+ w.doubleValue()+1,
+ h.doubleValue()+1);
+ drawer.getLinePath().reset();
+
+ drawer.getLinePath().append( rect, false );
+ //graphics.drawRect((int)x.doubleValue(), (int)(pageSize.getHeight() - y.doubleValue()),
+ // (int)w.doubleValue(),(int)h.doubleValue() );
+ //System.out.println( "<re x=\"" + x.getValue() + "\" y=\"" + y.getValue() + "\" width=\"" +
+ // width.getValue() + "\" height=\"" + height.getValue() + "\" >" );
+ }
+}
diff --git a/src/main/java/org/pdfbox/util/operator/pagedrawer/BeginInlineImage.java b/src/main/java/org/pdfbox/util/operator/pagedrawer/BeginInlineImage.java
new file mode 100644
index 0000000..9031345
--- /dev/null
+++ b/src/main/java/org/pdfbox/util/operator/pagedrawer/BeginInlineImage.java
@@ -0,0 +1,114 @@
+/**
+ * Copyright (c) 2005, www.pdfbox.org
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of pdfbox; nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * http://www.pdfbox.org
+ *
+ */
+package org.pdfbox.util.operator.pagedrawer;
+
+import java.awt.Graphics2D;
+import java.awt.geom.AffineTransform;
+import java.awt.image.BufferedImage;
+import java.io.IOException;
+import java.util.List;
+
+import org.pdfbox.pdfviewer.PageDrawer;
+import org.pdfbox.pdmodel.graphics.xobject.PDInlinedImage;
+import org.pdfbox.util.ImageParameters;
+import org.pdfbox.util.Matrix;
+import org.pdfbox.util.PDFOperator;
+import org.pdfbox.util.operator.OperatorProcessor;
+
+/**
+ * Implementation of content stream operator for page drawer.
+ *
+ * @author Ben Litchfield (ben@benlitchfield.com)
+ * @version $Revision: 1.1 $
+ */
+public class BeginInlineImage extends OperatorProcessor
+{
+
+
+ /**
+ * process : BI : begin inline image.
+ * @param operator The operator that is being executed.
+ * @param arguments List
+ * @throws IOException If there is an error displaying the inline image.
+ */
+ public void process(PDFOperator operator, List arguments) throws IOException
+ {
+ PageDrawer drawer = (PageDrawer)context;
+ Graphics2D graphics = drawer.getGraphics();
+ //begin inline image object
+ ImageParameters params = operator.getImageParameters();
+ PDInlinedImage image = new PDInlinedImage();
+ image.setImageParameters( params );
+ image.setImageData( operator.getImageData() );
+ BufferedImage awtImage = image.createImage();
+
+ Matrix ctm = drawer.getGraphicsState().getCurrentTransformationMatrix();
+
+ int width = awtImage.getWidth();
+ int height = awtImage.getHeight();
+
+
+ AffineTransform at = new AffineTransform(
+ ctm.getValue(0,0)/width,
+ ctm.getValue(0,1),
+ ctm.getValue(1,0),
+ ctm.getValue(1,1)/height,
+ ctm.getValue(2,0),
+ ctm.getValue(2,1)
+ );
+ //at.setToRotation((double)page.getRotation());
+
+
+ // The transformation should be done
+ // 1 - Translation
+ // 2 - Rotation
+ // 3 - Scale or Skew
+ //AffineTransform at = new AffineTransform();
+
+ // Translation
+ //at = new AffineTransform();
+ //at.setToTranslation((double)ctm.getValue(0,0),
+ // (double)ctm.getValue(0,1));
+
+ // Rotation
+ //AffineTransform toAdd = new AffineTransform();
+ //toAdd.setToRotation(1.5705);
+ //toAdd.setToRotation(ctm.getValue(2,0)*(Math.PI/180));
+ //at.concatenate(toAdd);
+
+ // Scale / Skew?
+ //toAdd.setToScale(width, height);
+ //at.concatenate(toAdd);
+ //at.setToScale( width, height );
+ graphics.drawImage( awtImage, at, null );
+ //graphics.drawImage( awtImage,0,0, width,height,null);
+ }
+}
diff --git a/src/main/java/org/pdfbox/util/operator/pagedrawer/ClosePath.java b/src/main/java/org/pdfbox/util/operator/pagedrawer/ClosePath.java
new file mode 100644
index 0000000..418af6d
--- /dev/null
+++ b/src/main/java/org/pdfbox/util/operator/pagedrawer/ClosePath.java
@@ -0,0 +1,59 @@
+/**
+ * Copyright (c) 2004, www.pdfbox.org
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of pdfbox; nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * http://www.pdfbox.org
+ *
+ */
+package org.pdfbox.util.operator.pagedrawer;
+
+import java.util.List;
+
+import org.pdfbox.pdfviewer.PageDrawer;
+import org.pdfbox.util.PDFOperator;
+import org.pdfbox.util.operator.OperatorProcessor;
+
+/**
+ * Implementation of content stream operator for page drawer.
+ *
+ * @author Ben Litchfield (ben@benlitchfield.com)
+ * @version $Revision: 1.1 $
+ */
+public class ClosePath extends OperatorProcessor
+{
+
+
+ /**
+ * process : h : Close path.
+ * @param operator The operator that is being executed.
+ * @param arguments List
+ */
+ public void process(PDFOperator operator, List arguments)
+ {
+ PageDrawer drawer = (PageDrawer)context;
+ drawer.getLinePath().closePath();
+ }
+}
diff --git a/src/main/java/org/pdfbox/util/operator/pagedrawer/CurveTo.java b/src/main/java/org/pdfbox/util/operator/pagedrawer/CurveTo.java
new file mode 100644
index 0000000..c056b91
--- /dev/null
+++ b/src/main/java/org/pdfbox/util/operator/pagedrawer/CurveTo.java
@@ -0,0 +1,73 @@
+/**
+ * Copyright (c) 2005, www.pdfbox.org
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of pdfbox; nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * http://www.pdfbox.org
+ *
+ */
+package org.pdfbox.util.operator.pagedrawer;
+
+import java.util.List;
+
+import org.pdfbox.cos.COSNumber;
+import org.pdfbox.pdfviewer.PageDrawer;
+import org.pdfbox.util.PDFOperator;
+import org.pdfbox.util.operator.OperatorProcessor;
+
+/**
+ * Implementation of content stream operator for page drawer.
+ *
+ * @author Ben Litchfield (ben@benlitchfield.com)
+ * @version $Revision: 1.1 $
+ */
+public class CurveTo extends OperatorProcessor
+{
+
+
+ /**
+ * process : c : Append curved segment to path.
+ * @param operator The operator that is being executed.
+ * @param arguments List
+ */
+ public void process(PDFOperator operator, List arguments)
+ {
+ PageDrawer drawer = (PageDrawer)context;
+
+ COSNumber x1 = (COSNumber)arguments.get( 0 );
+ COSNumber y1 = (COSNumber)arguments.get( 1 );
+ COSNumber x2 = (COSNumber)arguments.get( 2 );
+ COSNumber y2 = (COSNumber)arguments.get( 3 );
+ COSNumber x3 = (COSNumber)arguments.get( 4 );
+ COSNumber y3 = (COSNumber)arguments.get( 5 );
+ float x1f = x1.floatValue();
+ float y1f = (float)drawer.fixY( x1f, y1.floatValue() );
+ float x2f = x2.floatValue();
+ float y2f = (float)drawer.fixY( x2f, y2.floatValue() );
+ float x3f = x3.floatValue();
+ float y3f = (float)drawer.fixY( x3f, y3.floatValue() );
+ drawer.getLinePath().curveTo(x1f,y1f,x2f,y2f,x3f,y3f);
+ }
+}
diff --git a/src/main/java/org/pdfbox/util/operator/pagedrawer/CurveToReplicateFinalPoint.java b/src/main/java/org/pdfbox/util/operator/pagedrawer/CurveToReplicateFinalPoint.java
new file mode 100644
index 0000000..670cdb3
--- /dev/null
+++ b/src/main/java/org/pdfbox/util/operator/pagedrawer/CurveToReplicateFinalPoint.java
@@ -0,0 +1,69 @@
+/**
+ * Copyright (c) 2005, www.pdfbox.org
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of pdfbox; nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * http://www.pdfbox.org
+ *
+ */
+package org.pdfbox.util.operator.pagedrawer;
+
+import java.util.List;
+
+import org.pdfbox.cos.COSNumber;
+import org.pdfbox.pdfviewer.PageDrawer;
+import org.pdfbox.util.PDFOperator;
+import org.pdfbox.util.operator.OperatorProcessor;
+
+/**
+ * Implementation of content stream operator for page drawer.
+ *
+ * @author Ben Litchfield (ben@benlitchfield.com)
+ * @version $Revision: 1.1 $
+ */
+public class CurveToReplicateFinalPoint extends OperatorProcessor
+{
+
+
+ /**
+ * process : y : Append curved segment to path (final point replicated).
+ * @param operator The operator that is being executed.
+ * @param arguments List
+ */
+ public void process(PDFOperator operator, List arguments)
+ {
+ PageDrawer drawer = (PageDrawer)context;
+
+ COSNumber x1 = (COSNumber)arguments.get( 0 );
+ COSNumber y1 = (COSNumber)arguments.get( 1 );
+ COSNumber x3 = (COSNumber)arguments.get( 2 );
+ COSNumber y3 = (COSNumber)arguments.get( 3 );
+ float x1f = x1.floatValue();
+ float y1f = (float)drawer.fixY( x1f, y1.floatValue() );
+ float x3f = x3.floatValue();
+ float y3f = (float)drawer.fixY( x3f, y3.floatValue() );
+ drawer.getLinePath().curveTo(x1f,y1f,x3f,y3f,x3f,y3f);
+ }
+}
diff --git a/src/main/java/org/pdfbox/util/operator/pagedrawer/CurveToReplicateInitialPoint.java b/src/main/java/org/pdfbox/util/operator/pagedrawer/CurveToReplicateInitialPoint.java
new file mode 100644
index 0000000..ff354d0
--- /dev/null
+++ b/src/main/java/org/pdfbox/util/operator/pagedrawer/CurveToReplicateInitialPoint.java
@@ -0,0 +1,76 @@
+/**
+ * Copyright (c) 2005, www.pdfbox.org
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of pdfbox; nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * http://www.pdfbox.org
+ *
+ */
+package org.pdfbox.util.operator.pagedrawer;
+
+import java.awt.geom.GeneralPath;
+import java.awt.geom.Point2D;
+import java.util.List;
+
+import org.pdfbox.cos.COSNumber;
+import org.pdfbox.pdfviewer.PageDrawer;
+import org.pdfbox.util.PDFOperator;
+import org.pdfbox.util.operator.OperatorProcessor;
+
+/**
+ * Implementation of content stream operator for page drawer.
+ *
+ * @author Ben Litchfield (ben@benlitchfield.com)
+ * @version $Revision: 1.1 $
+ */
+public class CurveToReplicateInitialPoint extends OperatorProcessor
+{
+
+
+ /**
+ * process : v : Append curved segment to path (initial point replicated).
+ * @param operator The operator that is being executed.
+ * @param arguments List
+ */
+ public void process(PDFOperator operator, List arguments)
+ {
+ PageDrawer drawer = (PageDrawer)context;
+
+ COSNumber x2 = (COSNumber)arguments.get( 0 );
+ COSNumber y2 = (COSNumber)arguments.get( 1 );
+ COSNumber x3 = (COSNumber)arguments.get( 2 );
+ COSNumber y3 = (COSNumber)arguments.get( 3 );
+ float x2f = x2.floatValue();
+ float y2f = (float)drawer.fixY( x2f, y2.floatValue() );
+ float x3f = x3.floatValue();
+ float y3f = (float)drawer.fixY( x3f, y3.floatValue() );
+
+ GeneralPath path = drawer.getLinePath();
+ Point2D currentPoint = path.getCurrentPoint();
+ float currentX = (float)currentPoint.getX();
+ float currentY = (float)currentPoint.getY();
+ drawer.getLinePath().curveTo(currentX,currentY,x2f,y2f,x3f,y3f);
+ }
+}
diff --git a/src/main/java/org/pdfbox/util/operator/pagedrawer/FillEvenOddRule.java b/src/main/java/org/pdfbox/util/operator/pagedrawer/FillEvenOddRule.java
new file mode 100644
index 0000000..da9e834
--- /dev/null
+++ b/src/main/java/org/pdfbox/util/operator/pagedrawer/FillEvenOddRule.java
@@ -0,0 +1,71 @@
+/**
+ * Copyright (c) 2005, www.pdfbox.org
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of pdfbox; nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * http://www.pdfbox.org
+ *
+ */
+package org.pdfbox.util.operator.pagedrawer;
+
+import java.awt.Graphics2D;
+import java.awt.RenderingHints;
+import java.awt.geom.GeneralPath;
+import java.util.List;
+
+import org.pdfbox.pdfviewer.PageDrawer;
+import org.pdfbox.util.PDFOperator;
+import org.pdfbox.util.operator.OperatorProcessor;
+
+/**
+ * Implementation of content stream operator for page drawer.
+ *
+ * @author Ben Litchfield (ben@benlitchfield.com)
+ * @version $Revision: 1.1 $
+ */
+public class FillEvenOddRule extends OperatorProcessor
+{
+
+
+ /**
+ * process : f* : fill path using even odd rule.
+ * @param operator The operator that is being executed.
+ * @param arguments List
+ */
+ public void process(PDFOperator operator, List arguments)
+ {
+// NOTE:changes here should probably also be made to FillNonZeroRule
+ PageDrawer drawer = (PageDrawer)context;
+ Graphics2D graphics = drawer.getGraphics();
+ //linePath.closePath();
+ graphics.setColor( drawer.getNonStrokingColor() );
+ drawer.getLinePath().setWindingRule( GeneralPath.WIND_EVEN_ODD );
+ graphics.setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF );
+ //else
+ //{
+ graphics.fill( drawer.getLinePath() );
+ //}
+ }
+}
diff --git a/src/main/java/org/pdfbox/util/operator/pagedrawer/FillNonZeroRule.java b/src/main/java/org/pdfbox/util/operator/pagedrawer/FillNonZeroRule.java
new file mode 100644
index 0000000..56efa33
--- /dev/null
+++ b/src/main/java/org/pdfbox/util/operator/pagedrawer/FillNonZeroRule.java
@@ -0,0 +1,71 @@
+/**
+ * Copyright (c) 2005, www.pdfbox.org
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of pdfbox; nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * http://www.pdfbox.org
+ *
+ */
+package org.pdfbox.util.operator.pagedrawer;
+
+import java.awt.Graphics2D;
+import java.awt.RenderingHints;
+import java.awt.geom.GeneralPath;
+import java.util.List;
+
+import org.pdfbox.pdfviewer.PageDrawer;
+import org.pdfbox.util.PDFOperator;
+import org.pdfbox.util.operator.OperatorProcessor;
+
+/**
+ * Implementation of content stream operator for page drawer.
+ *
+ * @author Ben Litchfield (ben@benlitchfield.com)
+ * @version $Revision: 1.1 $
+ */
+public class FillNonZeroRule extends OperatorProcessor
+{
+
+
+ /**
+ * process : F/f : fill path using non zero winding rule.
+ * @param operator The operator that is being executed.
+ * @param arguments List
+ */
+ public void process(PDFOperator operator, List arguments)
+ {
+ //NOTE:changes here should probably also be made to FillEvenOddRule
+ PageDrawer drawer = (PageDrawer)context;
+ Graphics2D graphics = drawer.getGraphics();
+ //linePath.closePath();
+ graphics.setColor( drawer.getNonStrokingColor() );
+ drawer.getLinePath().setWindingRule( GeneralPath.WIND_NON_ZERO );
+ graphics.setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF );
+ //else
+ //{
+ graphics.fill( drawer.getLinePath() );
+ //}
+ }
+}
diff --git a/src/main/java/org/pdfbox/util/operator/pagedrawer/Invoke.java b/src/main/java/org/pdfbox/util/operator/pagedrawer/Invoke.java
new file mode 100644
index 0000000..3d99b74
--- /dev/null
+++ b/src/main/java/org/pdfbox/util/operator/pagedrawer/Invoke.java
@@ -0,0 +1,180 @@
+/**
+ * Copyright (c) 2005, www.pdfbox.org
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of pdfbox; nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * http://www.pdfbox.org
+ *
+ */
+package org.pdfbox.util.operator.pagedrawer;
+
+import java.awt.Dimension;
+import java.awt.Graphics2D;
+import java.awt.geom.AffineTransform;
+import java.awt.image.BufferedImage;
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.log4j.Logger;
+import org.pdfbox.cos.COSName;
+import org.pdfbox.pdfviewer.PageDrawer;
+import org.pdfbox.pdmodel.PDPage;
+import org.pdfbox.pdmodel.graphics.xobject.PDXObject;
+import org.pdfbox.pdmodel.graphics.xobject.PDXObjectImage;
+import org.pdfbox.util.Matrix;
+import org.pdfbox.util.PDFOperator;
+import org.pdfbox.util.operator.OperatorProcessor;
+
+/**
+ * Implementation of content stream operator for page drawer.
+ *
+ * @author Ben Litchfield (ben@benlitchfield.com)
+ * @version $Revision: 1.1 $
+ */
+public class Invoke extends OperatorProcessor
+{
+ private static Logger log = Logger.getLogger( Invoke.class );
+
+ /**
+ * process : re : append rectangle to path.
+ * @param operator The operator that is being executed.
+ * @param arguments List
+ * @throws IOException If there is an error invoking the sub object.
+ */
+ public void process(PDFOperator operator, List arguments) throws IOException
+ {
+ PageDrawer drawer = (PageDrawer)context;
+ PDPage page = drawer.getPage();
+ Dimension pageSize = drawer.getPageSize();
+ Graphics2D graphics = drawer.getGraphics();
+ COSName objectName = (COSName)arguments.get( 0 );
+ Map xobjects = drawer.getResources().getXObjects();
+ PDXObject xobject = (PDXObject)xobjects.get( objectName.getName() );
+ if( xobject instanceof PDXObjectImage )
+ {
+ PDXObjectImage image = (PDXObjectImage)xobject;
+ try
+ {
+ BufferedImage awtImage = image.getRGBImage();
+ Matrix ctm = drawer.getGraphicsState().getCurrentTransformationMatrix();
+
+ int width = awtImage.getWidth();
+ int height = awtImage.getHeight();
+
+ double rotationInRadians =(page.findRotation() * Math.PI)/180;
+
+
+ AffineTransform rotation = new AffineTransform();
+ rotation.setToRotation( rotationInRadians );
+ AffineTransform rotationInverse = rotation.createInverse();
+ Matrix rotationInverseMatrix = new Matrix();
+ rotationInverseMatrix.setFromAffineTransform( rotationInverse );
+ Matrix rotationMatrix = new Matrix();
+ rotationMatrix.setFromAffineTransform( rotation );
+
+ Matrix unrotatedCTM = ctm.multiply( rotationInverseMatrix );
+
+ Matrix scalingParams = unrotatedCTM.extractScaling();
+ Matrix scalingMatrix = Matrix.getScaleInstance(1f/width,1f/height);
+ scalingParams = scalingParams.multiply( scalingMatrix );
+
+ Matrix translationParams = unrotatedCTM.extractTranslating();
+ Matrix translationMatrix = null;
+ int pageRotation = page.findRotation();
+ if( pageRotation == 0 )
+ {
+ translationParams.setValue(2,1, -translationParams.getValue( 2,1 ));
+ translationMatrix = Matrix.getTranslatingInstance(
+ 0, (float)pageSize.getHeight()-height*scalingParams.getYScale() );
+ }
+ else if( pageRotation == 90 )
+ {
+ translationMatrix = Matrix.getTranslatingInstance( 0, (float)pageSize.getHeight() );
+ }
+ else
+ {
+ //TODO need to figure out other cases
+ }
+ translationParams = translationParams.multiply( translationMatrix );
+
+ AffineTransform at = new AffineTransform(
+ scalingParams.getValue( 0,0), 0,
+ 0, scalingParams.getValue( 1, 1),
+ translationParams.getValue(2,0), translationParams.getValue( 2,1 )
+ );
+
+
+
+
+ //at.setToTranslation( pageSize.getHeight()-ctm.getValue(2,0),ctm.getValue(2,1) );
+ //at.setToScale( ctm.getValue(0,0)/width, ctm.getValue(1,1)/height);
+ //at.setToRotation( (page.findRotation() * Math.PI)/180 );
+
+
+
+ //AffineTransform rotation = new AffineTransform();
+ //rotation.rotate( (90*Math.PI)/180);
+
+ /*
+
+ // The transformation should be done
+ // 1 - Translation
+ // 2 - Rotation
+ // 3 - Scale or Skew
+ AffineTransform at = new AffineTransform();
+
+ // Translation
+ at = new AffineTransform();
+ //at.setToTranslation((double)ctm.getValue(0,0),
+ // (double)ctm.getValue(0,1));
+
+ // Rotation
+ //AffineTransform toAdd = new AffineTransform();
+ toAdd.setToRotation(1.5705);
+ toAdd.setToRotation(ctm.getValue(2,0)*(Math.PI/180));
+ at.concatenate(toAdd);
+ */
+
+ // Scale / Skew?
+ //toAdd.setToScale(1, 1);
+ //at.concatenate(toAdd);
+
+ graphics.drawImage( awtImage, at, null );
+ }
+ catch( Exception e )
+ {
+ e.printStackTrace();
+ }
+ }
+ else
+ {
+ log.warn( "Unknown xobject type:" + xobject );
+ }
+
+
+ //invoke named object.
+ }
+}
diff --git a/src/main/java/org/pdfbox/util/operator/pagedrawer/LineTo.java b/src/main/java/org/pdfbox/util/operator/pagedrawer/LineTo.java
new file mode 100644
index 0000000..a70099b
--- /dev/null
+++ b/src/main/java/org/pdfbox/util/operator/pagedrawer/LineTo.java
@@ -0,0 +1,65 @@
+/**
+ * Copyright (c) 2005, www.pdfbox.org
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of pdfbox; nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * http://www.pdfbox.org
+ *
+ */
+package org.pdfbox.util.operator.pagedrawer;
+
+import java.util.List;
+
+import org.pdfbox.cos.COSNumber;
+import org.pdfbox.pdfviewer.PageDrawer;
+import org.pdfbox.util.PDFOperator;
+import org.pdfbox.util.operator.OperatorProcessor;
+
+/**
+ * Implementation of content stream operator for page drawer.
+ *
+ * @author Ben Litchfield (ben@benlitchfield.com)
+ * @version $Revision: 1.1 $
+ */
+public class LineTo extends OperatorProcessor
+{
+
+
+ /**
+ * process : l : Append straight line segment to path.
+ * @param operator The operator that is being executed.
+ * @param arguments List
+ */
+ public void process(PDFOperator operator, List arguments)
+ {
+ PageDrawer drawer = (PageDrawer)context;
+
+ //append straight line segment from the current point to the point.
+ COSNumber x = (COSNumber)arguments.get( 0 );
+ COSNumber y = (COSNumber)arguments.get( 1 );
+
+ drawer.getLinePath().lineTo( x.floatValue(), (float)drawer.fixY( x.doubleValue(), y.doubleValue()) );
+ }
+}
diff --git a/src/main/java/org/pdfbox/util/operator/pagedrawer/MoveTo.java b/src/main/java/org/pdfbox/util/operator/pagedrawer/MoveTo.java
new file mode 100644
index 0000000..e1c8f1e
--- /dev/null
+++ b/src/main/java/org/pdfbox/util/operator/pagedrawer/MoveTo.java
@@ -0,0 +1,68 @@
+/**
+ * Copyright (c) 2005, www.pdfbox.org
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of pdfbox; nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * http://www.pdfbox.org
+ *
+ */
+package org.pdfbox.util.operator.pagedrawer;
+
+import java.awt.geom.GeneralPath;
+import java.util.List;
+
+import org.pdfbox.cos.COSNumber;
+import org.pdfbox.pdfviewer.PageDrawer;
+import org.pdfbox.util.PDFOperator;
+import org.pdfbox.util.operator.OperatorProcessor;
+
+/**
+ * Implementation of content stream operator for page drawer.
+ *
+ * @author Ben Litchfield (ben@benlitchfield.com)
+ * @version $Revision: 1.1 $
+ */
+public class MoveTo extends OperatorProcessor
+{
+
+
+ /**
+ * process : m : Begin new subpath.
+ * @param operator The operator that is being executed.
+ * @param arguments List
+ */
+ public void process(PDFOperator operator, List arguments)
+ {
+ PageDrawer drawer = (PageDrawer)context;
+
+ COSNumber x = (COSNumber)arguments.get( 0 );
+ COSNumber y = (COSNumber)arguments.get( 1 );
+
+ drawer.getLineSubPaths().add( drawer.getLinePath() );
+ GeneralPath newPath = new GeneralPath();
+ newPath.moveTo( x.floatValue(), (float)drawer.fixY( x.doubleValue(), y.doubleValue()) );
+ drawer.setLinePath( newPath );
+ }
+}
diff --git a/src/main/java/org/pdfbox/util/operator/pagedrawer/SetLineWidth.java b/src/main/java/org/pdfbox/util/operator/pagedrawer/SetLineWidth.java
new file mode 100644
index 0000000..4217451
--- /dev/null
+++ b/src/main/java/org/pdfbox/util/operator/pagedrawer/SetLineWidth.java
@@ -0,0 +1,65 @@
+/**
+ * Copyright (c) 2005, www.pdfbox.org
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of pdfbox; nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * http://www.pdfbox.org
+ *
+ */
+package org.pdfbox.util.operator.pagedrawer;
+
+import java.util.List;
+import org.pdfbox.pdfviewer.PageDrawer;
+import org.pdfbox.util.PDFOperator;
+
+import java.awt.BasicStroke;
+import java.io.IOException;
+
+/**
+ * Implementation of content stream operator for page drawer.
+ *
+ * @author Ben Litchfield (ben@benlitchfield.com)
+ * @version $Revision: 1.1 $
+ */
+public class SetLineWidth extends org.pdfbox.util.operator.SetLineWidth
+{
+
+ /**
+ * w Set line width.
+ * @param operator The operator that is being executed.
+ * @param arguments List
+ * @throws IOException If an error occurs while processing the font.
+ */
+ public void process(PDFOperator operator, List arguments) throws IOException
+ {
+ super.process( operator, arguments );
+ float lineWidth = (float)context.getGraphicsState().getLineWidth();
+ if( lineWidth == 0 )
+ {
+ lineWidth = 1;
+ }
+ ((PageDrawer)context).getGraphics().setStroke( new BasicStroke( lineWidth ) );
+ }
+}
diff --git a/src/main/java/org/pdfbox/util/operator/pagedrawer/SetNonStrokingCMYKColor.java b/src/main/java/org/pdfbox/util/operator/pagedrawer/SetNonStrokingCMYKColor.java
new file mode 100644
index 0000000..d1c37fe
--- /dev/null
+++ b/src/main/java/org/pdfbox/util/operator/pagedrawer/SetNonStrokingCMYKColor.java
@@ -0,0 +1,64 @@
+/**
+ * Copyright (c) 2005, www.pdfbox.org
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of pdfbox; nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * http://www.pdfbox.org
+ *
+ */
+package org.pdfbox.util.operator.pagedrawer;
+
+import java.util.List;
+
+import java.awt.Color;
+import java.io.IOException;
+
+import org.pdfbox.pdfviewer.PageDrawer;
+import org.pdfbox.pdmodel.graphics.color.PDColorSpaceInstance;
+import org.pdfbox.util.PDFOperator;
+
+/**
+ * Implementation of content stream operator for page drawer.
+ *
+ * @author Ben Litchfield (ben@benlitchfield.com)
+ * @version $Revision: 1.1 $
+ */
+public class SetNonStrokingCMYKColor extends org.pdfbox.util.operator.SetNonStrokingCMYKColor
+{
+ /**
+ * k Set color space for non stroking operations.
+ * @param operator The operator that is being executed.
+ * @param arguments List
+ * @throws IOException If an error occurs while processing the font.
+ */
+ public void process(PDFOperator operator, List arguments) throws IOException
+ {
+ super.process( operator, arguments );
+ PageDrawer drawer = (PageDrawer)context;
+ PDColorSpaceInstance colorInstance = drawer.getGraphicsState().getNonStrokingColorSpace();
+ Color color = colorInstance.createColor();
+ drawer.setNonStrokingColor( color );
+ }
+}
diff --git a/src/main/java/org/pdfbox/util/operator/pagedrawer/SetNonStrokingColorSpace.java b/src/main/java/org/pdfbox/util/operator/pagedrawer/SetNonStrokingColorSpace.java
new file mode 100644
index 0000000..e5abae8
--- /dev/null
+++ b/src/main/java/org/pdfbox/util/operator/pagedrawer/SetNonStrokingColorSpace.java
@@ -0,0 +1,71 @@
+/**
+ * Copyright (c) 2005, www.pdfbox.org
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of pdfbox; nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * http://www.pdfbox.org
+ *
+ */
+package org.pdfbox.util.operator.pagedrawer;
+
+import java.util.List;
+import org.pdfbox.pdfviewer.PageDrawer;
+import org.pdfbox.pdmodel.graphics.color.PDColorSpaceInstance;
+import org.pdfbox.util.PDFOperator;
+
+
+import java.awt.Color;
+import java.io.IOException;
+
+/**
+ * Implementation of content stream operator for page drawer.
+ *
+ * @author Ben Litchfield (ben@benlitchfield.com)
+ * @version $Revision: 1.1 $
+ */
+public class SetNonStrokingColorSpace extends org.pdfbox.util.operator.SetNonStrokingColorSpace
+{
+ /**
+ * cs Set color space for non stroking operations.
+ * @param operator The operator that is being executed.
+ * @param arguments List
+ * @throws IOException If an error occurs while processing the font.
+ */
+ public void process(PDFOperator operator, List arguments) throws IOException
+ {
+ try
+ {
+ super.process( operator, arguments );
+ PageDrawer drawer = (PageDrawer)context;
+ PDColorSpaceInstance colorInstance = drawer.getGraphicsState().getNonStrokingColorSpace();
+ Color color = colorInstance.createColor();
+ drawer.setNonStrokingColor( color );
+ }
+ catch( IOException e )
+ {
+ //ignore for now and continue drawing
+ }
+ }
+}
diff --git a/src/main/java/org/pdfbox/util/operator/pagedrawer/SetNonStrokingRGBColor.java b/src/main/java/org/pdfbox/util/operator/pagedrawer/SetNonStrokingRGBColor.java
new file mode 100644
index 0000000..f816d1f
--- /dev/null
+++ b/src/main/java/org/pdfbox/util/operator/pagedrawer/SetNonStrokingRGBColor.java
@@ -0,0 +1,65 @@
+/**
+ * Copyright (c) 2005, www.pdfbox.org
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of pdfbox; nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * http://www.pdfbox.org
+ *
+ */
+package org.pdfbox.util.operator.pagedrawer;
+
+import java.util.List;
+
+import java.awt.Color;
+import java.io.IOException;
+
+import org.pdfbox.cos.COSNumber;
+import org.pdfbox.pdfviewer.PageDrawer;
+import org.pdfbox.util.PDFOperator;
+
+/**
+ * Implementation of content stream operator for page drawer.
+ *
+ * @author Ben Litchfield (ben@benlitchfield.com)
+ * @version $Revision: 1.1 $
+ */
+public class SetNonStrokingRGBColor extends org.pdfbox.util.operator.SetNonStrokingRGBColor
+{
+ /**
+ * rg Set color space for non stroking operations.
+ * @param operator The operator that is being executed.
+ * @param arguments List
+ * @throws IOException If an error occurs while processing the font.
+ */
+ public void process(PDFOperator operator, List arguments) throws IOException
+ {
+ super.process( operator, arguments );
+ PageDrawer drawer = (PageDrawer)context;
+ COSNumber r = (COSNumber)arguments.get( 0 );
+ COSNumber g = (COSNumber)arguments.get( 1 );
+ COSNumber b = (COSNumber)arguments.get( 2 );
+ drawer.setNonStrokingColor( new Color( r.floatValue(), g.floatValue(), b.floatValue() ) );
+ }
+}
diff --git a/src/main/java/org/pdfbox/util/operator/pagedrawer/SetStrokingCMYKColor.java b/src/main/java/org/pdfbox/util/operator/pagedrawer/SetStrokingCMYKColor.java
new file mode 100644
index 0000000..81fcef3
--- /dev/null
+++ b/src/main/java/org/pdfbox/util/operator/pagedrawer/SetStrokingCMYKColor.java
@@ -0,0 +1,64 @@
+/**
+ * Copyright (c) 2005, www.pdfbox.org
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of pdfbox; nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * http://www.pdfbox.org
+ *
+ */
+package org.pdfbox.util.operator.pagedrawer;
+
+import java.util.List;
+
+import java.awt.Color;
+import java.io.IOException;
+
+import org.pdfbox.pdfviewer.PageDrawer;
+import org.pdfbox.pdmodel.graphics.color.PDColorSpaceInstance;
+import org.pdfbox.util.PDFOperator;
+
+/**
+ * Implementation of content stream operator for page drawer.
+ *
+ * @author Ben Litchfield (ben@benlitchfield.com)
+ * @version $Revision: 1.1 $
+ */
+public class SetStrokingCMYKColor extends org.pdfbox.util.operator.SetStrokingCMYKColor
+{
+ /**
+ * CS Set color space for stroking operations.
+ * @param operator The operator that is being executed.
+ * @param arguments List
+ * @throws IOException If an error occurs while processing the font.
+ */
+ public void process(PDFOperator operator, List arguments) throws IOException
+ {
+ super.process( operator, arguments );
+ PageDrawer drawer = (PageDrawer)context;
+ PDColorSpaceInstance colorInstance = drawer.getGraphicsState().getNonStrokingColorSpace();
+ Color color = colorInstance.createColor();
+ drawer.setStrokingColor( color );
+ }
+}
diff --git a/src/main/java/org/pdfbox/util/operator/pagedrawer/SetStrokingColorSpace.java b/src/main/java/org/pdfbox/util/operator/pagedrawer/SetStrokingColorSpace.java
new file mode 100644
index 0000000..22c9c5c
--- /dev/null
+++ b/src/main/java/org/pdfbox/util/operator/pagedrawer/SetStrokingColorSpace.java
@@ -0,0 +1,70 @@
+/**
+ * Copyright (c) 2005, www.pdfbox.org
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of pdfbox; nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * http://www.pdfbox.org
+ *
+ */
+package org.pdfbox.util.operator.pagedrawer;
+
+import java.util.List;
+import org.pdfbox.pdfviewer.PageDrawer;
+import org.pdfbox.pdmodel.graphics.color.PDColorSpaceInstance;
+import org.pdfbox.util.PDFOperator;
+
+import java.awt.Color;
+import java.io.IOException;
+
+/**
+ * Implementation of content stream operator for page drawer.
+ *
+ * @author Ben Litchfield (ben@benlitchfield.com)
+ * @version $Revision: 1.1 $
+ */
+public class SetStrokingColorSpace extends org.pdfbox.util.operator.SetNonStrokingColorSpace
+{
+ /**
+ * CS Set color space for stroking operations.
+ * @param operator The operator that is being executed.
+ * @param arguments List
+ * @throws IOException If an error occurs while processing the font.
+ */
+ public void process(PDFOperator operator, List arguments) throws IOException
+ {
+ super.process( operator, arguments );
+ try
+ {
+ PageDrawer drawer = (PageDrawer)context;
+ PDColorSpaceInstance colorInstance = drawer.getGraphicsState().getNonStrokingColorSpace();
+ Color color = colorInstance.createColor();
+ drawer.setStrokingColor( color );
+ }
+ catch( IOException e )
+ {
+ //ignore for now and continue drawing
+ }
+ }
+}
diff --git a/src/main/java/org/pdfbox/util/operator/pagedrawer/SetStrokingRGBColor.java b/src/main/java/org/pdfbox/util/operator/pagedrawer/SetStrokingRGBColor.java
new file mode 100644
index 0000000..8d7099e
--- /dev/null
+++ b/src/main/java/org/pdfbox/util/operator/pagedrawer/SetStrokingRGBColor.java
@@ -0,0 +1,65 @@
+/**
+ * Copyright (c) 2005, www.pdfbox.org
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of pdfbox; nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * http://www.pdfbox.org
+ *
+ */
+package org.pdfbox.util.operator.pagedrawer;
+
+import java.util.List;
+
+import java.awt.Color;
+import java.io.IOException;
+
+import org.pdfbox.cos.COSNumber;
+import org.pdfbox.pdfviewer.PageDrawer;
+import org.pdfbox.util.PDFOperator;
+
+/**
+ * Implementation of content stream operator for page drawer.
+ *
+ * @author Ben Litchfield (ben@benlitchfield.com)
+ * @version $Revision: 1.1 $
+ */
+public class SetStrokingRGBColor extends org.pdfbox.util.operator.SetStrokingRGBColor
+{
+ /**
+ * RG Set color space for stroking operations.
+ * @param operator The operator that is being executed.
+ * @param arguments List
+ * @throws IOException If an error occurs while processing the font.
+ */
+ public void process(PDFOperator operator, List arguments) throws IOException
+ {
+ super.process( operator, arguments );
+ PageDrawer drawer = (PageDrawer)context;
+ COSNumber r = (COSNumber)arguments.get( 0 );
+ COSNumber g = (COSNumber)arguments.get( 1 );
+ COSNumber b = (COSNumber)arguments.get( 2 );
+ drawer.setStrokingColor( new Color( r.floatValue(), g.floatValue(), b.floatValue() ) );
+ }
+}
diff --git a/src/main/java/org/pdfbox/util/operator/pagedrawer/StrokePath.java b/src/main/java/org/pdfbox/util/operator/pagedrawer/StrokePath.java
new file mode 100644
index 0000000..31a489c
--- /dev/null
+++ b/src/main/java/org/pdfbox/util/operator/pagedrawer/StrokePath.java
@@ -0,0 +1,73 @@
+/**
+ * Copyright (c) 2005, www.pdfbox.org
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of pdfbox; nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * http://www.pdfbox.org
+ *
+ */
+package org.pdfbox.util.operator.pagedrawer;
+
+import java.util.List;
+import org.pdfbox.pdfviewer.PageDrawer;
+import org.pdfbox.util.PDFOperator;
+
+import java.awt.Graphics2D;
+import java.awt.geom.GeneralPath;
+import java.io.IOException;
+
+/**
+ * Implementation of content stream operator for page drawer.
+ *
+ * @author Ben Litchfield (ben@benlitchfield.com)
+ * @version $Revision: 1.1 $
+ */
+public class StrokePath extends org.pdfbox.util.operator.SetLineWidth
+{
+
+ /**
+ * S stroke the path.
+ * @param operator The operator that is being executed.
+ * @param arguments List
+ *
+ * @throws IOException If an error occurs while processing the font.
+ */
+ public void process(PDFOperator operator, List arguments) throws IOException
+ {
+ PageDrawer drawer = (PageDrawer)context;
+ Graphics2D graphics = ((PageDrawer)context).getGraphics();
+ graphics.setColor( drawer.getStrokingColor() );
+ List subPaths = drawer.getLineSubPaths();
+ for( int i=0; i<subPaths.size(); i++ )
+ {
+ GeneralPath subPath = (GeneralPath)subPaths.get( i );
+ graphics.draw( subPath );
+ }
+ subPaths.clear();
+ GeneralPath path = drawer.getLinePath();
+ graphics.draw( path );
+ path.reset();
+ }
+}
diff --git a/src/main/java/org/pdfbox/util/operator/pagedrawer/package.html b/src/main/java/org/pdfbox/util/operator/pagedrawer/package.html
new file mode 100644
index 0000000..edb8444
--- /dev/null
+++ b/src/main/java/org/pdfbox/util/operator/pagedrawer/package.html
@@ -0,0 +1,9 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+<head>
+
+</head>
+<body>
+This package contains implementations of all of the PDF operators.
+</body>
+</html>