Components All New MacOS Windows Linux iOS
Examples Mac & Win Server Client Guides Statistic FMM Blog Deprecated Old

DynaPDF.PlaceTemplate

The function places a template on a page, another open template, or pattern.

Component Version macOS Windows Linux Server iOS SDK
DynaPDF 3.3 ✅ Yes ✅ Yes ✅ Yes ✅ Yes ✅ Yes
MBS( "DynaPDF.PlaceTemplate"; PDF; TemplateHandle; X; Y; W; H )   More

Parameters

Parameter Description Example
PDF The PDF reference returned from DynaPDF.New. $pdf
TemplateHandle The handle value returned from DynaPDF.ImportPageAsTemplate function. $template
X The x coordinate. $x
Y The y coordinate. Please notice that PDF coordinates start at bottom of page except you change that with DynaPDF.SetPageCoords functions. $y
W The width of the destination rectangle. $w
H The height of the destination rectangle. $h

Result

Returns OK or error message.

Description

The function places a template on a page, another open template, or pattern.
The parameter TemplateHandle must be a valid template handle that was returned by DynaPDF.BeginTemplate or DynaPDF.ImportPageAsTemplate.
Templates can be used multiple times on different pages or positions and with different sizes. Unlike images, a template can be scaled without losing quality as far as the template contains vector graphics and text objects only.
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 template.
  • 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 mirrored).
  • A negative value of Width or Height mirrors the template on the x- or y-axis.

Imported pages can contain non-normalized bounding boxes and the page can be rotated. The coordinate origin, crop box, and rotation angle of a page must be considered when placing a template on a page because templates do not support features like a crop box or individual orientation angles. The required calculations to find the correct coordinate origin and to de- rotate a template are relatively complex. Therefore, DynaPDF provides the function DynaPDF.PlaceTemplateEx which considers the, coordinate origin, orientation angle, and crop box automatically. DynaPDF.PlaceTemplateEx greatly simplifies the handling of templates. If possible, this function should be used when working with imported pages.

Remarks: A template is invisible as long it was not placed on a page, template, or pattern. Templates should not be used inside of patterns because this requires usually too much rendering time.

See also PlaceTemplate function in DynaPDF manual.

See also

Blog Entries

This function checks for a license.

Created 18th August 2014, last changed 26th May 2018


DynaPDF.PlaceSigFieldValidateIcon - DynaPDF.PlaceTemplateEx