Xojo Conferences
MBSOct2019CologneDE

DynaPDF Manual - Page 565

Previous Page 564   Index   Next Page 566

Function Reference
Page 565 of 767
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.
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.
Return values:
If the function succeeds the return value is 1. If the function fails the return value is 0.
Example (C++)
The following code collects 6 imported pages on one destination page. The imported pages are
placed horizontally and vertically centered into a fixed destination rectangle.
// This is our error callback function
SI32 PDF_CALL PDFError(const void* Data, SI32 ErrCode,
const char* ErrMessage, SI32 ErrType)
{
printf("%s\n", ErrMessage);
return 0;
}
// This function places a template horizontally and vertically centered
// into a destination rectangle
SI32 PlaceCenteredEx(const void* PDF, // Instance pointer
SI32 Tmpl,
// Template handle
double SrcWidth,
// Logical page width
double SrcHeight,
// Logical page height
double DestX,
// Destination x-coordinate
double DestY,
// Destination y-coordinate
double DestWidth,
// Destination width
double DestHeight) // Destination height
{
double x, y, w, h, sx;
 

Previous topic: PlaceTemplateEx

Next topic: PlaceTemplByMatrix