DynaPDF Manual - Page 583

Previous Page 582   Index   Next Page 584

Function Reference
Page 583 of 787
Return values:
If the function succeeds the return value is 1. If the function fails the return value is 0.
LBOOL pdfPlaceTemplateEx(
const PPDF* IPDF,
// Instance pointer
SI32 TmplHandle,
// Template handle
double PosX,
// X-Coordinate
double PosY,
// Y-Coordinate
double ScaleWidth,
// Scaled width
double ScaleHeight) // Scaled height
The function places a template on a page, another open template, or pattern. The parameter
TmplHandle must be a valid template handle that was returned by BeginTemplate(), ImportPage() or
The function was specifically designed to work with templates which were created from imported
pages. A PDF page is converted to a template if it was imported with ImportPage() or
ImportPageEx() outside of an open page.
The calculation of the width and height is the same as for images:
If Width or Height is -1 the function uses the mirrored original width or height from the
If Width or Height is 0, the missing value is calculated in relation to the given value of Height
or Width to preserve the template's aspect ratio. The resulting output is a template with exact
proportions relative to its original size.
If Width and Height are 0, the original size is used (same effect as -1 but the template is not
A negative value of Width or Height mirrors the template on the x- or y-axis.
A template does not support a crop box or orientation angle. When placing a template on a page
that was created from an imported PDF page, the coordinate origin must be adjusted according to
the original media or crop box. In addition, the template must maybe be drawn into a clipping path
(if the original page contained a crop box), and the template must maybe also be rotated so that the
original orientation can be preserved.
All these considerations complicate the handling of imported templates. To make the usage easier
the function considers the coordinate origin, it draws the template automatically into a clipping
rectangle if required, and it rotates the template according to the original page orientation.
The only thing that must be considered is that the original size of the template must be calculated
from the crop box if present. In addition, the so computed width and height must be exchanged if
the original page orientation was 90, -90, 270, or -270 degrees. See example below.

Previous topic: PlaceTemplate

Next topic: PlaceTemplByMatrix, PolygonAnnot

Start Chat