Xojo Developer Conference
25/27th April 2018 in Denver.
MBS Xojo Conference
6/7th September 2018 in Munich, Germany.

DynaPDF Manual - Page 491

Previous Page 490   Index   Next Page 492

Function Reference
Page 491 of 750
InsertMetafileEx
Syntax:
LBOOL pdfInsertMetafileEx(
const PPDF* IPDF,
// Instance pointer
const void* Buffer, // Metafile buffer
UI32 BufSize,
// Buffer length
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 a native PDF
vector graphic in the same way as InsertMetafile(). However, this function requires a file buffer that
was returned by the API function GetEnhMetaFileBits(), GetWinMetaFileBits() or
GetMetaFileBitsEx(). Buffer can also be a file buffer of an EMF or WMF file.
This function is mostly used to convert EMF files which were already loaded into memory or
displayed on screen. Those memory based EMF or WMF files can directly be converted to PDF as
follows:
In this example we have already a handle of an enhanced metafile. This handle can be used to get the
file buffer of the EMF file:
Example 1 (C++):
// First, we need the size of the file buffer
SI32 bufSize = GetEnhMetaFileBits(emf, 0, NULL);
BYTE* buffer = (BYTE*)malloc(bufSize); // Allocate memory
if (!buffer) return -1; // Out of memory?
// Now we can get the file buffer
bufSize = GetEnhMetaFileBits(emf, bufSize, buffer);
// We convert the buffer directly to PDF
pdfSetPageCoords(pdf, pcTopDown);
pdfInsertMetafileEx(pdf, buffer, bufSize, 0, 0, pdfGetPageWidth(pdf), 0);
// Free the buffer
free(buffer);
Example 2 (Delphi):
// emf is a TMetafile; we store the buffer in a TMemoryStream
emf.SaveToStream(stream);
pdf.InsertMetafileEx(stream.Memory,stream.Size,0,0,pdf.GetPageWidth,0);
Return values:
If the function succeeds the return value is 1. If the function fails the return value is 0.
 

Previous topic: Compatibility Note:

Next topic: InsertMetafileExtEx