pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From le...@apache.org
Subject svn commit: r1566720 - in /pdfbox/trunk: examples/src/main/java/org/apache/pdfbox/examples/util/ pdfbox/src/main/java/org/apache/pdfbox/pdfviewer/ pdfbox/src/main/java/org/apache/pdfbox/pdmodel/ pdfbox/src/main/java/org/apache/pdfbox/util/ pdfbox/src/m...
Date Mon, 10 Feb 2014 19:54:03 GMT
Author: lehmi
Date: Mon Feb 10 19:54:02 2014
New Revision: 1566720

URL: http://svn.apache.org/r1566720
Log:
PDFBOX-1905: removed page reference in PageDrawer and PDFStreamEngine

Modified:
    pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/util/PrintImageLocations.java
    pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/util/PrintTextLocations.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfviewer/PDFPagePanel.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfviewer/PageDrawer.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPageable.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/PDFStreamEngine.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/PDFTextStripper.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/RenderUtil.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/operator/Invoke.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/operator/pagedrawer/Invoke.java
    pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/content/ContentStreamWrapper.java
    pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/Type3FontValidator.java
    pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/util/PDFAType3StreamParser.java

Modified: pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/util/PrintImageLocations.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/util/PrintImageLocations.java?rev=1566720&r1=1566719&r2=1566720&view=diff
==============================================================================
--- pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/util/PrintImageLocations.java
(original)
+++ pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/util/PrintImageLocations.java
Mon Feb 10 19:54:02 2014
@@ -19,7 +19,6 @@ package org.apache.pdfbox.examples.util;
 import org.apache.pdfbox.cos.COSName;
 import org.apache.pdfbox.cos.COSStream;
 import org.apache.pdfbox.exceptions.InvalidPasswordException;
-import org.apache.pdfbox.exceptions.WrappedIOException;
 
 import org.apache.pdfbox.pdmodel.PDDocument;
 import org.apache.pdfbox.pdmodel.PDPage;
@@ -34,7 +33,6 @@ import org.apache.pdfbox.util.PDFStreamE
 import org.apache.pdfbox.util.ResourceLoader;
 
 import java.awt.geom.AffineTransform;
-import java.awt.geom.NoninvertibleTransformException;
 import java.io.IOException;
 
 import java.util.List;
@@ -100,7 +98,8 @@ public class PrintImageLocations extends
                 {
                     PDPage page = (PDPage)allPages.get( i );
                     System.out.println( "Processing page: " + i );
-                    printer.processStream( page, page.findResources(), page.getContents().getStream()
);
+                    printer.processStream( page.findResources(), page.getContents().getStream(),
+                    		page.findCropBox(), page.findRotation() );
                 }
             }
             finally
@@ -132,30 +131,19 @@ public class PrintImageLocations extends
             if( xobject instanceof PDXObjectImage )
             {
                 PDXObjectImage image = (PDXObjectImage)xobject;
-                PDPage page = getCurrentPage();
                 int imageWidth = image.getWidth();
                 int imageHeight = image.getHeight();
-                double pageHeight = page.getMediaBox().getHeight();
                 System.out.println("*******************************************************************");
                 System.out.println("Found image [" + objectName.getName() + "]");
         
                 Matrix ctmNew = getGraphicsState().getCurrentTransformationMatrix();
-                float yScaling = ctmNew.getYScale();
-                float angle = (float)Math.acos(ctmNew.getValue(0, 0)/ctmNew.getXScale());
-                if (ctmNew.getValue(0, 1) < 0 && ctmNew.getValue(1, 0) > 0)
-                {
-                    angle = (-1)*angle;
-                }
-                ctmNew.setValue(2, 1, (float)(pageHeight - ctmNew.getYPosition() - Math.cos(angle)*yScaling));
-                ctmNew.setValue(2, 0, (float)(ctmNew.getXPosition() - Math.sin(angle)*yScaling));
-                // because of the moved 0,0-reference, we have to shear in the opposite direction
-                ctmNew.setValue(0, 1, (-1)*ctmNew.getValue(0, 1));
-                ctmNew.setValue(1, 0, (-1)*ctmNew.getValue(1, 0));
-                AffineTransform ctmAT = ctmNew.createAffineTransform();
-                ctmAT.scale(1f/imageWidth, 1f/imageHeight);
+                AffineTransform imageTransform = ctmNew.createAffineTransform();
+                imageTransform.scale(1.0 / imageWidth, -1.0 / imageHeight);
+                imageTransform.translate(0, -imageHeight);
 
-                float imageXScale = ctmNew.getXScale();
-                float imageYScale = ctmNew.getYScale();
+                
+                double imageXScale = imageTransform.getScaleX();
+                double imageYScale = imageTransform.getScaleY();
                 System.out.println("position = " + ctmNew.getXPosition() + ", " + ctmNew.getYPosition());
                 // size in pixel
                 System.out.println("size = " + imageWidth + "px, " + imageHeight + "px");
@@ -175,24 +163,18 @@ public class PrintImageLocations extends
             {
                 // save the graphics state
                 getGraphicsStack().push( (PDGraphicsState)getGraphicsState().clone() );
-                PDPage page = getCurrentPage();
                 
                 PDXObjectForm form = (PDXObjectForm)xobject;
                 COSStream invoke = (COSStream)form.getCOSObject();
                 PDResources pdResources = form.getResources();
-                if(pdResources == null)
-                {
-                    pdResources = page.findResources();
-                }
-                // if there is an optional form matrix, we have to
-                // map the form space to the user space
+                // if there is an optional form matrix, we have to map the form space to
the user space
                 Matrix matrix = form.getMatrix();
                 if (matrix != null) 
                 {
                     Matrix xobjectCTM = matrix.multiply( getGraphicsState().getCurrentTransformationMatrix());
                     getGraphicsState().setCurrentTransformationMatrix(xobjectCTM);
                 }
-                processSubStream( page, pdResources, invoke );
+                processSubStream( pdResources, invoke );
                 
                 // restore the graphics state
                 setGraphicsState( (PDGraphicsState)getGraphicsStack().pop() );

Modified: pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/util/PrintTextLocations.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/util/PrintTextLocations.java?rev=1566720&r1=1566719&r2=1566720&view=diff
==============================================================================
--- pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/util/PrintTextLocations.java
(original)
+++ pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/util/PrintTextLocations.java
Mon Feb 10 19:54:02 2014
@@ -89,7 +89,8 @@ public class PrintTextLocations extends 
                     PDStream contents = page.getContents();
                     if( contents != null )
                     {
-                        printer.processStream( page, page.findResources(), page.getContents().getStream()
);
+                        printer.processStream( page.findResources(), page.getContents().getStream(),
+                        		page.findCropBox(), page.findRotation() );
                     }
                 }
             }

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfviewer/PDFPagePanel.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfviewer/PDFPagePanel.java?rev=1566720&r1=1566719&r2=1566720&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfviewer/PDFPagePanel.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfviewer/PDFPagePanel.java Mon Feb
10 19:54:02 2014
@@ -94,8 +94,8 @@ public class PDFPagePanel extends JPanel
                 g2D.translate(pageDimension.getWidth(), 0.0f);
                 g2D.rotate(Math.toRadians(rotation));
             }
-
-            drawer.drawPage( g, page, drawDimension );
+            PDRectangle pageSize = new PDRectangle((float)drawDimension.getWidth(), (float)drawDimension.getHeight());
+            drawer.drawPage( g, page, pageSize );
         }
         catch( IOException e )
         {

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfviewer/PageDrawer.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfviewer/PageDrawer.java?rev=1566720&r1=1566719&r2=1566720&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfviewer/PageDrawer.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfviewer/PageDrawer.java Mon Feb
10 19:54:02 2014
@@ -19,7 +19,6 @@ package org.apache.pdfbox.pdfviewer;
 import java.awt.BasicStroke;
 import java.awt.Color;
 import java.awt.Composite;
-import java.awt.Dimension;
 import java.awt.Font;
 import java.awt.Graphics;
 import java.awt.Graphics2D;
@@ -102,20 +101,13 @@ public class PageDrawer extends PDFStrea
      */
     private int clippingWindingRule = -1;
 
-    /**
-     * Size of the page.
-     */
-    protected Dimension pageSize;
-    /**
-     * Current page to be rendered.
-     */
-    protected PDPage page;
-
     private GeneralPath linePath = new GeneralPath();
 
     private Map<PDFont, Glyph2D> fontGlyph2D = new HashMap<PDFont, Glyph2D>();
     private Map<PDFont, Font> awtFonts = new HashMap<PDFont, Font>();
 
+    private int pageHeight;
+    
     /**
      * Default constructor, loads properties from file.
      * 
@@ -130,19 +122,18 @@ public class PageDrawer extends PDFStrea
      * This will draw the page to the requested context.
      * 
      * @param g The graphics context to draw onto.
-     * @param p The page to draw.
-     * @param pageDimension The size of the page to draw.
+     * @param page The page to draw.
+     * @param pageSize The size of the page to draw.
      * 
      * @throws IOException If there is an IO error while drawing the page.
      */
-    public void drawPage(Graphics g, PDPage p, Dimension pageDimension) throws IOException
+    public void drawPage(Graphics g, PDPage page, PDRectangle pageSize) throws IOException
     {
         graphics = (Graphics2D) g;
-        page = p;
-        pageSize = pageDimension;
+        pageHeight = (int)pageSize.getHeight();
         graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
         graphics.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
-        graphics.translate(0, pageSize.height);
+        graphics.translate(0, pageHeight);
         graphics.scale(1, -1);
         // initialize the used stroke with CAP_BUTT instead of CAP_SQUARE
         graphics.setStroke(new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER));
@@ -151,7 +142,7 @@ public class PageDrawer extends PDFStrea
         if (page.getContents() != null)
         {
             PDResources resources = page.findResources();
-            processStream(page, resources, page.getContents().getStream());
+            processStream(resources, page.getContents().getStream(), page.findCropBox(),
page.findRotation());
         }
         List<PDAnnotation> annotations = page.getAnnotations();
         for (int i = 0; i < annotations.size(); i++)
@@ -182,7 +173,7 @@ public class PageDrawer extends PDFStrea
                             at.transform(point, point);
                         }
                         graphics.translate((int) point.getX(), -(int) point.getY());
-                        processSubStream(page, appearance.getResources(), appearance.getStream());
+                        processSubStream(appearance.getResources(), appearance.getStream());
                         graphics.translate(-(int) point.getX(), (int) point.getY());
                     }
                 }
@@ -211,8 +202,6 @@ public class PageDrawer extends PDFStrea
         }
         graphics = null;
         linePath = null;
-        page = null;
-        pageSize = null;
     }
 
     /**
@@ -234,7 +223,7 @@ public class PageDrawer extends PDFStrea
                 paint = graphicsState.getNonStrokingColor().getJavaColor();
                 if (paint == null)
                 {
-                    paint = graphicsState.getNonStrokingColor().getPaint(pageSize.height);
+                    paint = graphicsState.getNonStrokingColor().getPaint(pageHeight);
                 }
                 break;
             case PDTextState.RENDERING_MODE_STROKE_TEXT:
@@ -242,7 +231,7 @@ public class PageDrawer extends PDFStrea
                 paint = graphicsState.getStrokingColor().getJavaColor();
                 if (paint == null)
                 {
-                    paint = graphicsState.getStrokingColor().getPaint(pageSize.height);
+                    paint = graphicsState.getStrokingColor().getPaint(pageHeight);
                 }
                 break;
             case PDTextState.RENDERING_MODE_NEITHER_FILL_NOR_STROKE_TEXT:
@@ -355,8 +344,8 @@ public class PageDrawer extends PDFStrea
      */
     private void drawType3String(PDType3Font font, TextPosition text, AffineTransform at)
throws IOException
     {
-    	int[] codePoints = text.getCodePoints();
-    	int textLength = codePoints.length;
+        int[] codePoints = text.getCodePoints();
+        int textLength = codePoints.length;
         for (int i = 0; i < textLength; i++)
         {
             COSStream stream = font.getCharStream((char)codePoints[i]);
@@ -368,7 +357,7 @@ public class PageDrawer extends PDFStrea
                 Matrix ctm = new Matrix();
                 ctm.setFromAffineTransform(at);
                 getGraphicsState().setCurrentTransformationMatrix(ctm);
-                processSubStream(page, font.getType3Resources(), stream);
+                processSubStream(font.getType3Resources(), stream);
 
                 // restore the saved graphics state
                 setGraphicsState((PDGraphicsState) getGraphicsStack().pop());
@@ -583,26 +572,6 @@ public class PageDrawer extends PDFStrea
     }
 
     /**
-     * Get the page that is currently being drawn.
-     * 
-     * @return The page that is being drawn.
-     */
-    public PDPage getPage()
-    {
-        return page;
-    }
-
-    /**
-     * Get the size of the page that is currently being drawn.
-     * 
-     * @return The size of the page that is being drawn.
-     */
-    public Dimension getPageSize()
-    {
-        return pageSize;
-    }
-
-    /**
      * Get the current line path to be drawn.
      * 
      * @return The current line path to be drawn.
@@ -642,7 +611,7 @@ public class PageDrawer extends PDFStrea
         Paint nonStrokingPaint = getGraphicsState().getNonStrokingColor().getJavaColor();
         if (nonStrokingPaint == null)
         {
-            nonStrokingPaint = getGraphicsState().getNonStrokingColor().getPaint(pageSize.height);
+            nonStrokingPaint = getGraphicsState().getNonStrokingColor().getPaint(pageHeight);
         }
         if (nonStrokingPaint == null)
         {
@@ -691,7 +660,7 @@ public class PageDrawer extends PDFStrea
         Paint strokingPaint = getGraphicsState().getStrokingColor().getJavaColor();
         if (strokingPaint == null)
         {
-            strokingPaint = getGraphicsState().getStrokingColor().getPaint(pageSize.height);
+            strokingPaint = getGraphicsState().getStrokingColor().getPaint(pageHeight);
         }
         if (strokingPaint == null)
         {
@@ -842,10 +811,10 @@ public class PageDrawer extends PDFStrea
             LOG.debug("Function based shading not yet supported");
             break;
         case 2:
-            paint = new AxialShadingPaint((PDShadingType2) shading, ctm, pageSize.height);
+            paint = new AxialShadingPaint((PDShadingType2) shading, ctm, pageHeight);
             break;
         case 3:
-            paint = new RadialShadingPaint((PDShadingType3) shading, ctm, pageSize.height);
+            paint = new RadialShadingPaint((PDShadingType3) shading, ctm, pageHeight);
             break;
         case 4:
         case 5:

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPageable.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPageable.java?rev=1566720&r1=1566719&r2=1566720&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPageable.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPageable.java Mon Feb 10
19:54:02 2014
@@ -190,9 +190,8 @@ public class PDPageable implements Pagea
             try
             {
                 PDPage page = pages.get(i);
-                PDRectangle cropBox = page.findCropBox();
                 PageDrawer drawer = new PageDrawer();
-                drawer.drawPage(graphics, page, cropBox.createDimension());
+                drawer.drawPage(graphics, page, page.findCropBox());
                 drawer.dispose();
                 return PAGE_EXISTS;
             }

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/PDFStreamEngine.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/PDFStreamEngine.java?rev=1566720&r1=1566719&r2=1566720&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/PDFStreamEngine.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/PDFStreamEngine.java Mon Feb
10 19:54:02 2014
@@ -36,9 +36,9 @@ import org.apache.pdfbox.cos.COSObject;
 import org.apache.pdfbox.cos.COSStream;
 import org.apache.pdfbox.exceptions.WrappedIOException;
 import org.apache.pdfbox.pdfparser.PDFStreamParser;
-import org.apache.pdfbox.pdmodel.PDPage;
 import org.apache.pdfbox.pdmodel.PDResources;
 import org.apache.pdfbox.pdmodel.common.PDMatrix;
+import org.apache.pdfbox.pdmodel.common.PDRectangle;
 import org.apache.pdfbox.pdmodel.font.PDFont;
 import org.apache.pdfbox.pdmodel.font.PDType3Font;
 import org.apache.pdfbox.pdmodel.graphics.PDExtendedGraphicsState;
@@ -53,7 +53,7 @@ import org.apache.pdfbox.util.operator.O
  * class.
  * 
  * @author <a href="mailto:ben@benlitchfield.com">Ben Litchfield</a>
- * @version $Revision: 1.38 $
+ * 
  */
 public class PDFStreamEngine
 {
@@ -78,11 +78,12 @@ public class PDFStreamEngine
 
     private Stack<PDResources> streamResourcesStack = new Stack<PDResources>();
 
-    private PDPage page;
-
     private int validCharCnt;
     private int totalCharCnt;
 
+    private int pageRotation = 0;
+    private PDRectangle drawingRectangle = null;
+    
     /**
      * Flag to skip malformed or otherwise unparseable input where possible.
      */
@@ -183,40 +184,42 @@ public class PDFStreamEngine
     {
         validCharCnt = 0;
         totalCharCnt = 0;
+        drawingRectangle = null;
     }
 
     /**
      * This will process the contents of the stream.
      * 
-     * @param aPage The page.
      * @param resources The location to retrieve resources.
      * @param cosStream the Stream to execute.
-     * 
+     * @param drawingSize the size of the page
+     * @param rotation the page rotation
      * 
      * @throws IOException if there is an error accessing the stream.
      */
-    public void processStream(PDPage aPage, PDResources resources, COSStream cosStream) throws
IOException
+    public void processStream(PDResources resources, COSStream cosStream, PDRectangle drawingSize,
int rotation)
+            throws IOException
     {
-        graphicsState = new PDGraphicsState(aPage.findCropBox());
+        drawingRectangle = drawingSize;
+        pageRotation = rotation;
+        graphicsState = new PDGraphicsState(drawingRectangle);
         textMatrix = null;
         textLineMatrix = null;
         graphicsStack.clear();
         streamResourcesStack.clear();
-        processSubStream(aPage, resources, cosStream);
+        processSubStream(resources, cosStream);
     }
 
     /**
      * Process a sub stream of the current stream.
      * 
-     * @param aPage The page used for drawing.
      * @param resources The resources used when processing the stream.
      * @param cosStream The stream to process.
      * 
      * @throws IOException If there is an exception while processing the stream.
      */
-    public void processSubStream(PDPage aPage, PDResources resources, COSStream cosStream)
throws IOException
+    public void processSubStream(PDResources resources, COSStream cosStream) throws IOException
     {
-        page = aPage;
         if (resources != null)
         {
             streamResourcesStack.push(resources);
@@ -286,6 +289,8 @@ public class PDFStreamEngine
      * encoded by a glyph.
      * 
      * @param str The string to be processed.
+     * 
+     * @return the processed string.
      */
     protected String inspectFontEncoding(String str)
     {
@@ -362,9 +367,8 @@ public class PDFStreamEngine
         textStateParameters.setValue(1, 1, fontSizeText);
         textStateParameters.setValue(2, 1, riseText);
 
-        int pageRotation = page.findRotation();
-        float pageHeight = page.findCropBox().getHeight();
-        float pageWidth = page.findCropBox().getWidth();
+        float pageHeight = drawingRectangle.getHeight();
+        float pageWidth = drawingRectangle.getWidth();
 
         Matrix ctm = getGraphicsState().getCurrentTransformationMatrix();
         Matrix textXctm = new Matrix();
@@ -677,16 +681,6 @@ public class PDFStreamEngine
     }
 
     /**
-     * Get the current page that is being processed.
-     * 
-     * @return The page being processed.
-     */
-    public PDPage getCurrentPage()
-    {
-        return page;
-    }
-
-    /**
      * Get the total number of valid characters in the doc that could be decoded in processEncodedText().
      * 
      * @return The number of valid characters.

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/PDFTextStripper.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/PDFTextStripper.java?rev=1566720&r1=1566719&r2=1566720&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/PDFTextStripper.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/PDFTextStripper.java Mon Feb
10 19:54:02 2014
@@ -453,7 +453,7 @@ public class PDFTextStripper extends PDF
                 }
             }
             characterListMapping.clear();
-            processStream( page, page.findResources(), content );
+            processStream( page.findResources(), content, page.findCropBox(), page.findRotation()
);
             writePage();
             endPage( page );
         }

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/RenderUtil.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/RenderUtil.java?rev=1566720&r1=1566719&r2=1566720&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/RenderUtil.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/RenderUtil.java Mon Feb 10 19:54:02
2014
@@ -209,8 +209,7 @@ public class RenderUtil
         }
         graphics.scale(scaleX, scaleY);
         PageDrawer drawer = new PageDrawer();
-        // TODO The following reduces accuracy. It should really be a Dimension2D.Float.
-        drawer.drawPage(graphics, page, page.findCropBox().createDimension());
+        drawer.drawPage(graphics, page, page.findCropBox());
         drawer.dispose();
     }
 }

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/operator/Invoke.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/operator/Invoke.java?rev=1566720&r1=1566719&r2=1566720&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/operator/Invoke.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/operator/Invoke.java Mon Feb
10 19:54:02 2014
@@ -72,7 +72,7 @@ public class Invoke extends OperatorProc
             }
             // find some optional resources, instead of using the current resources
             PDResources pdResources = form.getResources();
-            context.processSubStream( context.getCurrentPage(), pdResources, formContentstream
);
+            context.processSubStream( pdResources, formContentstream );
         }
     }
 }

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/operator/pagedrawer/Invoke.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/operator/pagedrawer/Invoke.java?rev=1566720&r1=1566719&r2=1566720&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/operator/pagedrawer/Invoke.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/operator/pagedrawer/Invoke.java
Mon Feb 10 19:54:02 2014
@@ -28,7 +28,6 @@ import org.apache.pdfbox.cos.COSBase;
 import org.apache.pdfbox.cos.COSName;
 import org.apache.pdfbox.cos.COSStream;
 import org.apache.pdfbox.pdfviewer.PageDrawer;
-import org.apache.pdfbox.pdmodel.PDPage;
 import org.apache.pdfbox.pdmodel.PDResources;
 import org.apache.pdfbox.pdmodel.graphics.PDGraphicsState;
 import org.apache.pdfbox.pdmodel.graphics.xobject.PDXObject;
@@ -62,7 +61,6 @@ public class Invoke extends OperatorProc
     public void process(PDFOperator operator, List<COSBase> arguments) throws IOException
     {
         PageDrawer drawer = (PageDrawer) context;
-        PDPage page = drawer.getPage();
         COSName objectName = (COSName) arguments.get(0);
         Map<String, PDXObject> xobjects = drawer.getResources().getXObjects();
         PDXObject xobject = (PDXObject) xobjects.get(objectName.getName());
@@ -105,7 +103,7 @@ public class Invoke extends OperatorProc
         else if (xobject instanceof PDXObjectForm)
         {
             // save the graphics state
-            context.getGraphicsStack().push((PDGraphicsState) context.getGraphicsState().clone());
+        	drawer.getGraphicsStack().push((PDGraphicsState) drawer.getGraphicsState().clone());
 
             PDXObjectForm form = (PDXObjectForm) xobject;
             COSStream formContentstream = form.getCOSStream();
@@ -115,13 +113,13 @@ public class Invoke extends OperatorProc
             Matrix matrix = form.getMatrix();
             if (matrix != null)
             {
-                Matrix xobjectCTM = matrix.multiply(context.getGraphicsState().getCurrentTransformationMatrix());
-                context.getGraphicsState().setCurrentTransformationMatrix(xobjectCTM);
+                Matrix xobjectCTM = matrix.multiply(drawer.getGraphicsState().getCurrentTransformationMatrix());
+                drawer.getGraphicsState().setCurrentTransformationMatrix(xobjectCTM);
             }
-            getContext().processSubStream(page, pdResources, formContentstream);
+            drawer.processSubStream(pdResources, formContentstream);
 
             // restore the graphics state
-            context.setGraphicsState((PDGraphicsState) context.getGraphicsStack().pop());
+            drawer.setGraphicsState((PDGraphicsState) drawer.getGraphicsStack().pop());
         }
     }
 }

Modified: pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/content/ContentStreamWrapper.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/content/ContentStreamWrapper.java?rev=1566720&r1=1566719&r2=1566720&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/content/ContentStreamWrapper.java
(original)
+++ pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/content/ContentStreamWrapper.java
Mon Feb 10 19:54:02 2014
@@ -73,7 +73,8 @@ public class ContentStreamWrapper extend
             PDStream pstream = this.processeedPage.getContents();
             if (pstream != null)
             {
-                processStream(processeedPage, processeedPage.findResources(), pstream.getStream());
+                processStream(processeedPage.findResources(), pstream.getStream(), 
+                		processeedPage.findCropBox(), processeedPage.findRotation());
             }
         }
         catch (ContentStreamException e)
@@ -98,7 +99,7 @@ public class ContentStreamWrapper extend
         try
         {
             resetEnginContext();
-            processSubStream(this.processeedPage, xobj.getResources(), xobj.getCOSStream());
+            processSubStream(xobj.getResources(), xobj.getCOSStream());
         }
         catch (ContentStreamException e)
         {
@@ -123,7 +124,7 @@ public class ContentStreamWrapper extend
         {
             COSDictionary res = (COSDictionary) pattern.getDictionaryObject(COSName.RESOURCES);
             resetEnginContext();
-            processSubStream(this.processeedPage, new PDResources(res), pattern);
+            processSubStream(new PDResources(res), pattern);
         }
         catch (ContentStreamException e)
         {

Modified: pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/Type3FontValidator.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/Type3FontValidator.java?rev=1566720&r1=1566719&r2=1566720&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/Type3FontValidator.java
(original)
+++ pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/Type3FontValidator.java
Mon Feb 10 19:54:02 2014
@@ -406,7 +406,7 @@ public class Type3FontValidator extends 
         PreflightPath vPath = context.getValidationPath();
         PDFAType3StreamParser parser = new PDFAType3StreamParser(context, vPath.getClosestPathElement(PDPage.class));
         parser.resetEngine();
-        parser.processSubStream(null, resources, charStream);
+        parser.processSubStream(resources, charStream);
         return parser.getWidth();
     }
 

Modified: pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/util/PDFAType3StreamParser.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/util/PDFAType3StreamParser.java?rev=1566720&r1=1566719&r2=1566720&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/util/PDFAType3StreamParser.java
(original)
+++ pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/util/PDFAType3StreamParser.java
Mon Feb 10 19:54:02 2014
@@ -68,7 +68,7 @@ public class PDFAType3StreamParser exten
     public Image createImage(COSStream type3Stream) throws IOException
     {
         resetEngine();
-        processSubStream(null, null, type3Stream);
+        processSubStream(null, type3Stream);
         return image.createImage();
     }
 



Mime
View raw message