Skip to content

Commit

Permalink
PDFBOX-3305: Add method to allow drawing of image with custom matrix
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1738183 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
jahewson committed Apr 7, 2016
1 parent 3116afe commit e7bdcf6
Showing 1 changed file with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,33 @@ public void drawImage(PDImageXObject image, float x, float y, float width, float
restoreGraphicsState();
}

/**
* 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.
*
Expand Down

0 comments on commit e7bdcf6

Please sign in to comment.