| 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 |
|---|---|---|
| The PDF reference returned from DynaPDF.New. | ||
| 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.
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.
Examples
Place page rotated:
Set Variable [ $pdf ; Value: MBS ( "DynaPDF.New" ) ]
# import pdf
Set Variable [ $r ; Value: MBS ( "DynaPDF.OpenPDFFromContainer" ; $pdf ; Render Page::Input PDF ) ]
Set Variable [ $template ; Value: MBS ( "DynaPDF.ImportPageAsTemplate"; $PDF; 1 ) ]
# check how big our template is
Set Variable [ $bOriginal ; Value: MBS ( "DynaPDF.GetTemplWidth" ; $pdf; $template ) ]
Set Variable [ $hOriginal ; Value: MBS ( "DynaPDF.GetTemplHeight" ; $pdf; $template ) ]
# now edit page
Set Variable [ $r ; Value: MBS ("DynaPDF.EditPage"; $pdf; 1 ) ]
# Rotation metadata to 0°
Set Variable [ $r ; Value: MBS ("DynaPDF.SetOrientation"; $pdf; 0 ) ]
# chage page size to size of template
Set Variable [ $r ; Value: MBS ( "DynaPDF.SetPageWidth"; $pdf ; $hOriginal ) ]
Set Variable [ $r ; Value: MBS ( "DynaPDF.SetPageHeight"; $pdf ; $bOriginal ) ]
# rotate page in center by 90° counter clockwise
Set Variable [ $r ; Value: MBS("DynaPDF.TranslateCoords"; $pdf; MBS("DynaPDF.GetPageWidth";$pdf)/2; MBS( "DynaPDF.GetPageHeight";$pdf)/2) & MBS("DynaPDF.RotateCoords"; $pdf; -90; 0; 0) & MBS("DynaPDF.TranslateCoords"; $pdf; -MBS( "DynaPDF.GetPageHeight";$pdf)/2; -MBS("DynaPDF.GetP… ]
# now place template and close page
Set Variable [ $r ; Value: MBS ( "DynaPDF.PlaceTemplate" ; $pdf ; $template ; 0 ; 0 ; $bOriginal ; $hOriginal ) ]
Set Variable [ $r ; Value: MBS ( "DynaPDF.EndPage" ; $pdf ) ]
# save
Set Field [ Render Page::Output Image ; MBS ( "DynaPDF.Save" ; $pdf ; "Quadrat.pdf" ) ]
Set Variable [ $r ; Value: MBS ( "DynaPDF.Release" ; $pdf ) ]
# import pdf
Set Variable [ $r ; Value: MBS ( "DynaPDF.OpenPDFFromContainer" ; $pdf ; Render Page::Input PDF ) ]
Set Variable [ $template ; Value: MBS ( "DynaPDF.ImportPageAsTemplate"; $PDF; 1 ) ]
# check how big our template is
Set Variable [ $bOriginal ; Value: MBS ( "DynaPDF.GetTemplWidth" ; $pdf; $template ) ]
Set Variable [ $hOriginal ; Value: MBS ( "DynaPDF.GetTemplHeight" ; $pdf; $template ) ]
# now edit page
Set Variable [ $r ; Value: MBS ("DynaPDF.EditPage"; $pdf; 1 ) ]
# Rotation metadata to 0°
Set Variable [ $r ; Value: MBS ("DynaPDF.SetOrientation"; $pdf; 0 ) ]
# chage page size to size of template
Set Variable [ $r ; Value: MBS ( "DynaPDF.SetPageWidth"; $pdf ; $hOriginal ) ]
Set Variable [ $r ; Value: MBS ( "DynaPDF.SetPageHeight"; $pdf ; $bOriginal ) ]
# rotate page in center by 90° counter clockwise
Set Variable [ $r ; Value: MBS("DynaPDF.TranslateCoords"; $pdf; MBS("DynaPDF.GetPageWidth";$pdf)/2; MBS( "DynaPDF.GetPageHeight";$pdf)/2) & MBS("DynaPDF.RotateCoords"; $pdf; -90; 0; 0) & MBS("DynaPDF.TranslateCoords"; $pdf; -MBS( "DynaPDF.GetPageHeight";$pdf)/2; -MBS("DynaPDF.GetP… ]
# now place template and close page
Set Variable [ $r ; Value: MBS ( "DynaPDF.PlaceTemplate" ; $pdf ; $template ; 0 ; 0 ; $bOriginal ; $hOriginal ) ]
Set Variable [ $r ; Value: MBS ( "DynaPDF.EndPage" ; $pdf ) ]
# save
Set Field [ Render Page::Output Image ; MBS ( "DynaPDF.Save" ; $pdf ; "Quadrat.pdf" ) ]
Set Variable [ $r ; Value: MBS ( "DynaPDF.Release" ; $pdf ) ]
See also
- DynaPDF.BeginTemplate
- DynaPDF.DeleteTemplate
- DynaPDF.DeleteTemplateEx
- DynaPDF.EditTemplate
- DynaPDF.EditTemplate2
- DynaPDF.RotateTemplate
- DynaPDF.Save
- DynaPDF.SetOrientation
- DynaPDF.SetPageCoords
- DynaPDF.TranslateCoords
Blog Entries
FileMaker Magazin
This function checks for a license.
Created 18th August 2014, last changed 26th April 2026