DynaPDF Manual - Page 567
Previous Page 566 Index Next Page 568
Function Reference
Page 567 of 860
InsertMetafile
Syntax:
LBOOL pdfInsertMetafile(
const PPDF* IPDF,
// Instance pointer
const char* FileName, // File path to EMF or WMF file
double PosX,
// X-Coordinate of output rectangle
double PosY,
// Y-Coordinate of output rectangle
double Width,
// Width of output rectangle
double Height)
// Height of output rectangle
The function converts an Enhanced Meta File (EMF) or Windows Meta File (WMF) to native PDF
vector graphics. The function requires an open page or template into which the metafile can be
drawn (see Append() or EditPage()). If a metafile should be used as fixed background on multiple
pages, then insert it into a template and place this template on the pages where it should be used
(see BeginTemplate() for further information). It is of course also possible to insert such a metafile
on each page separately, but this would waste processing time and disk space.
The point PosX, PosY defines the lower left corner of the output rectangle if the coordinate system is
bottom-up and the upper left corner otherwise.
Bounding box check
The function checks whether the resolution of the EMF file seems to be larger as 1800 DPI. If this is
the case then the rclBounds rectangle is used to calculate the picture size since this is mostly an
indication that the rclFrame rectangle was incorrectly calculated. If you need to process EMF files in
a higher resoultion as 1800 DPI then disable the bounding box check with the flag mfNoBBoxCheck.
See SetMetaConfFlags() for further information.
How to calculate the image size?
The calculation of the image size should be easy as possible. In most cases, metafiles must be
inserted with exact proportions. Therefore, all metafile functions support two special values to make
the calculation easier. The width and height can be calculated as follows:
• If Width or Height is -1 the function uses the original width or height from the image. If both
parameters are -1 the metafile will be inserted with a resolution 72 DPI. However, this is not
meaningful for metafiles because the logical size of a metafile is usually too large as if it
could be used. You should not produce EMF files in a resolution of 72 DPI.
• If Width or Height is 0, the missing value is calculated in relation to the given value of Height
or Width to preserve the metafile's aspect ratio. The resulting output is a vector graphic with
exact proportions relative to its original size.
• If Width and Height is 0, the original size is used (same effect as -1, should not be used).
• Negative values of Width or Height are ignored; the function uses always the absolute values.
Previous topic: InsertImageFromBuffer
Next topic: Font selection in EMF files, Character sets, Non-portable WMF files