pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From msahy...@apache.org
Subject svn commit: r1643664 - /pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/documentmanipulation/SuperimposePage.java
Date Sun, 07 Dec 2014 11:53:17 GMT
Author: msahyoun
Date: Sun Dec  7 11:53:16 2014
New Revision: 1643664

URL: http://svn.apache.org/r1643664
Log:
PDFBOX-2197 add transformation to sample

Modified:
    pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/documentmanipulation/SuperimposePage.java

Modified: pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/documentmanipulation/SuperimposePage.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/documentmanipulation/SuperimposePage.java?rev=1643664&r1=1643663&r2=1643664&view=diff
==============================================================================
--- pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/documentmanipulation/SuperimposePage.java
(original)
+++ pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/documentmanipulation/SuperimposePage.java
Sun Dec  7 11:53:16 2014
@@ -21,6 +21,7 @@ import java.io.File;
 
 import org.apache.pdfbox.pdmodel.PDDocument;
 import org.apache.pdfbox.pdmodel.PDPage;
+import org.apache.pdfbox.pdmodel.common.PDRectangle;
 import org.apache.pdfbox.pdmodel.edit.PDPageContentStream;
 import org.apache.pdfbox.pdmodel.font.PDFont;
 import org.apache.pdfbox.pdmodel.font.PDType1Font;
@@ -40,6 +41,11 @@ public class SuperimposePage {
             // Create a new document with some basic content
             PDDocument aDoc = new PDDocument();
             PDPage aPage = new PDPage();
+            
+            // get the page crop box. Will be used later to place the
+            // imported page.
+            PDRectangle cropBox = aPage.getCropBox();
+            
             aDoc.addPage(aPage);
 
             PDPageContentStream aContent = new PDPageContentStream(aDoc, aPage);
@@ -72,10 +78,10 @@ public class SuperimposePage {
             // Store the graphics state
             contentStream.appendRawCommands("q\n".getBytes("ISO-8859-1"));
 
-            // use a transformation to be able to scale and move easily
-            AffineTransform transform = new AffineTransform();
-
-            // draw the PDXObjectForm
+            // use some sample transformations 
+            AffineTransform transform = new AffineTransform(0, 0.5, -0.5, 0, cropBox.getWidth(),
0);
+            contentStream.drawXObject(mountable, transform);
+            transform = new AffineTransform(0.5, 0.5, -0.5, 0.5, 0.5 * cropBox.getWidth(),
0.2 * cropBox.getHeight());
             contentStream.drawXObject(mountable, transform);
 
             // restore former graphics state



Mime
View raw message