I am using itextpdf to merge some pdfs to a single one. What are the meanings of itextpdf pdfcontentbyte addtemplate's parameters,there is no docs to describe them.
public void addTemplate(PdfTemplate template,
double a, double b, double c, double d, double e, double f)
The six values a
, b
, c
, d
, e
, and f
are elements of a matrix that has three rows and three columns.
You can use this matrix to express a transformation in a two-dimentional system.
Carrying out this multiplication results in this:
x' = a * x + c * y + e
y' = b * x + d * y + f
The third column in the matrix is fixed: you're working in two dimensions, so you don't need to calculate a new z coordinate.
When studying analytical geometry in high school, you've probably learned how to apply transformations to objects. In PDF, we use a slightly different approach: instead of transforming objects, we transform the coordinate system.
The e
and the f
value can be used for a translation. The a
, b
, c
, and d
value can be used for a rotation and/or scaling operation.
By default the Current Transformation Matrix (CTM) is:
With the addTemplate()
method, you can add a Form XObject to a canvas and define a position using e
, f
, e.g:
canvas.addTemplate(template, 36, 36);
This will add template
at coordinate x = 36; y = 36.
By introducing a
, b
, c
, and d
, you can also rotate and/or scale the template
.
Update: as mentioned in the comments, you might want to use the overloaded methods that accept an AffineTransform
parameter if you don't like the Algebra of the transformation matrix.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With