You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ja...@apache.org on 2016/04/07 21:55:40 UTC
svn commit: r1738183 -
/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPageContentStream.java
Author: jahewson
Date: Thu Apr 7 19:55:40 2016
New Revision: 1738183
URL: http://svn.apache.org/viewvc?rev=1738183&view=rev
Log:
PDFBOX-3305: Add method to allow drawing of image with custom matrix
Modified:
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPageContentStream.java
Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPageContentStream.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPageContentStream.java?rev=1738183&r1=1738182&r2=1738183&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPageContentStream.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPageContentStream.java Thu Apr 7 19:55:40 2016
@@ -614,6 +614,33 @@ public final class PDPageContentStream i
}
/**
+ * Draw an image at the origin with the given transformation matrix.
+ *
+ * @param image The image to draw.
+ * @param matrix The transformation matrix to apply to the image.
+ *
+ * @throws IOException If there is an error writing to the stream.
+ * @throws IllegalStateException If the method was called within a text block.
+ */
+ public void drawImage(PDImageXObject image, Matrix matrix) throws IOException
+ {
+ if (inTextMode)
+ {
+ throw new IllegalStateException("Error: drawImage is not allowed within a text block.");
+ }
+
+ saveGraphicsState();
+
+ AffineTransform transform = matrix.createAffineTransform();
+ transform(new Matrix(transform));
+
+ writeOperand(resources.add(image));
+ writeOperator("Do");
+
+ restoreGraphicsState();
+ }
+
+ /**
* Draw an inline image at the x,y coordinates, with the default size of the image.
*
* @param inlineImage The inline image to draw.