xmlgraphics-fop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lberna...@apache.org
Subject svn commit: r1457280 - in /xmlgraphics/fop-pdf-images/trunk/src/java/org/apache/fop/render/pdf/pdfbox: AbstractPDFBoxHandler.java PDFBoxAdapter.java PDFBoxImageHandler.java
Date Sat, 16 Mar 2013 17:51:33 GMT
Author: lbernardo
Date: Sat Mar 16 17:51:32 2013
New Revision: 1457280

URL: http://svn.apache.org/r1457280
Log:
FOP-2216: PDF forms are offset; patch submitted by Simon Steiner

Modified:
    xmlgraphics/fop-pdf-images/trunk/src/java/org/apache/fop/render/pdf/pdfbox/AbstractPDFBoxHandler.java
    xmlgraphics/fop-pdf-images/trunk/src/java/org/apache/fop/render/pdf/pdfbox/PDFBoxAdapter.java
    xmlgraphics/fop-pdf-images/trunk/src/java/org/apache/fop/render/pdf/pdfbox/PDFBoxImageHandler.java

Modified: xmlgraphics/fop-pdf-images/trunk/src/java/org/apache/fop/render/pdf/pdfbox/AbstractPDFBoxHandler.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop-pdf-images/trunk/src/java/org/apache/fop/render/pdf/pdfbox/AbstractPDFBoxHandler.java?rev=1457280&r1=1457279&r2=1457280&view=diff
==============================================================================
--- xmlgraphics/fop-pdf-images/trunk/src/java/org/apache/fop/render/pdf/pdfbox/AbstractPDFBoxHandler.java
(original)
+++ xmlgraphics/fop-pdf-images/trunk/src/java/org/apache/fop/render/pdf/pdfbox/AbstractPDFBoxHandler.java
Sat Mar 16 17:51:32 2013
@@ -19,6 +19,7 @@
 
 package org.apache.fop.render.pdf.pdfbox;
 
+import java.awt.geom.AffineTransform;
 import java.io.IOException;
 import java.util.Collections;
 import java.util.HashMap;
@@ -63,7 +64,7 @@ public abstract class AbstractPDFBoxHand
             = Collections.synchronizedMap(new WeakHashMap<Object, Cache<String, Map<Object,
Object>>>());
 
     protected PDFFormXObject createFormForPDF(ImagePDF image,
-            PDFPage targetPage, FOUserAgent userAgent) throws IOException {
+            PDFPage targetPage, FOUserAgent userAgent, AffineTransform at) throws IOException
{
 
         EventBroadcaster eventBroadcaster = userAgent.getEventBroadcaster();
         String originalImageUri = image.getInfo().getOriginalURI();
@@ -104,7 +105,7 @@ public abstract class AbstractPDFBoxHand
 
         PDFBoxAdapter adapter = new PDFBoxAdapter(targetPage, objectCache);
         PDFFormXObject form = adapter.createFormFromPDFBoxPage(pddoc, page, originalImageUri,
-                eventBroadcaster);
+                eventBroadcaster, at);
         return form;
     }
 

Modified: xmlgraphics/fop-pdf-images/trunk/src/java/org/apache/fop/render/pdf/pdfbox/PDFBoxAdapter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop-pdf-images/trunk/src/java/org/apache/fop/render/pdf/pdfbox/PDFBoxAdapter.java?rev=1457280&r1=1457279&r2=1457280&view=diff
==============================================================================
--- xmlgraphics/fop-pdf-images/trunk/src/java/org/apache/fop/render/pdf/pdfbox/PDFBoxAdapter.java
(original)
+++ xmlgraphics/fop-pdf-images/trunk/src/java/org/apache/fop/render/pdf/pdfbox/PDFBoxAdapter.java
Sat Mar 16 17:51:32 2013
@@ -298,12 +298,13 @@ class PDFBoxAdapter {
      * @param sourceDoc the source PDF the given page to be copied belongs to
      * @param page the page to transform into a Form XObject
      * @param key value to use as key for the Form XObject
+     * @param atdoc adjustment for form
      * @return the Form XObject
      * @throws IOException if an I/O error occurs
      */
     public PDFFormXObject createFormFromPDFBoxPage(PDDocument sourceDoc, PDPage page, String
key,
-            EventBroadcaster eventBroadcaster) throws IOException {
-        handleAcroForm(sourceDoc, page, eventBroadcaster);
+            EventBroadcaster eventBroadcaster, AffineTransform atdoc) throws IOException
{
+        handleAcroForm(sourceDoc, page, eventBroadcaster, atdoc);
 
         PDResources sourcePageResources = page.findResources();
         PDFDictionary pageResources = null;
@@ -406,7 +407,7 @@ class PDFBoxAdapter {
     }
 
     private void handleAcroForm(PDDocument sourceDoc, PDPage page,
-            EventBroadcaster eventBroadcaster) throws IOException {
+            EventBroadcaster eventBroadcaster, AffineTransform at) throws IOException {
         PDDocumentCatalog srcCatalog = sourceDoc.getDocumentCatalog();
         PDAcroForm srcAcroForm = srcCatalog.getAcroForm();
         List pageWidgets = getWidgets(page);
@@ -414,6 +415,12 @@ class PDFBoxAdapter {
             return;
         }
 
+        for (Object obj : pageWidgets) {
+            PDAnnotation annot = (PDAnnotation)obj;
+            PDRectangle rect = annot.getRectangle();
+            rect.move((float)at.getTranslateX(), (float)at.getTranslateY());
+        }
+
         //Pseudo-cache the target page in place of the original source page.
         //This essentially replaces the original page reference with the target page.
         COSObject cosPage = null;

Modified: xmlgraphics/fop-pdf-images/trunk/src/java/org/apache/fop/render/pdf/pdfbox/PDFBoxImageHandler.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop-pdf-images/trunk/src/java/org/apache/fop/render/pdf/pdfbox/PDFBoxImageHandler.java?rev=1457280&r1=1457279&r2=1457280&view=diff
==============================================================================
--- xmlgraphics/fop-pdf-images/trunk/src/java/org/apache/fop/render/pdf/pdfbox/PDFBoxImageHandler.java
(original)
+++ xmlgraphics/fop-pdf-images/trunk/src/java/org/apache/fop/render/pdf/pdfbox/PDFBoxImageHandler.java
Sat Mar 16 17:51:32 2013
@@ -20,6 +20,7 @@
 package org.apache.fop.render.pdf.pdfbox;
 
 import java.awt.Rectangle;
+import java.awt.geom.AffineTransform;
 import java.io.IOException;
 
 import org.apache.commons.logging.Log;
@@ -54,16 +55,18 @@ public class PDFBoxImageHandler extends 
         PDFContentGenerator generator = pdfContext.getGenerator();
         ImagePDF pdfImage = (ImagePDF)image;
 
+        float x = (float)pos.getX() / 1000f;
+        float y = (float)pos.getY() / 1000f;
+        float w = (float)pos.getWidth() / 1000f;
+        float h = (float)pos.getHeight() / 1000f;
+
+        AffineTransform formadjust = generator.getAffineTransform();
         PDFFormXObject form = createFormForPDF(pdfImage, pdfContext.getPage(),
-                pdfContext.getUserAgent());
+                pdfContext.getUserAgent(), formadjust);
         if (form == null) {
             return;
         }
 
-        float x = (float)pos.getX() / 1000f;
-        float y = (float)pos.getY() / 1000f;
-        float w = (float)pos.getWidth() / 1000f;
-        float h = (float)pos.getHeight() / 1000f;
         generator.placeImage(x, y, w, h, form);
     }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org


Mime
View raw message