PDF Creator Pilot documentation |
Download CHM version of this manual. |
|
![]() ![]() Collapse AllFirst of all import the library in your project: #import "c:\\...\\PDFCreatorPilot.dll" // enter path here using namespace PDFCreatorPilotLib; Then you need to initialize a PDFDocument object: IPDFDocument4* PDF = NULL;
CLSID clsid_PDFCreatorPilot;
CLSIDFromProgID(OLESTR("PDFCreatorPilot.PDFDocument4"), &clsid_PDFCreatorPilot);
::CoCreateInstance(clsid_PDFCreatorPilot, NULL, CLSCTX_ALL, __uuidof(IPDFDocument4), (LPVOID*)&PDF);
if(PDF == NULL)
{
::CoUninitialize();
return 1;
}
After this you should call SetLicenseData method and adjust some properties if needed. Load EMF file to get its properties: width, height, resolution. You will need it to calculate scaleFactor. This value is needed to properly draw EMF file fited in PDF page. HENHMETAFILE hEmf = GetEnhMetaFile(emfFile);
MetafileDetails md = {0};
if(!GetMetafileDetails(hEmf, &md))
{
::CoUninitialize();
return 2;
}
// Scale factor based on the resolutions difference
double dScaleFactor = (double)PDF->PageResolution / (double)md.ResolutionY;
PDF->PageHeight = (long)(md.Height * dScaleFactor);
PDF->PageWidth = (long)(md.Width * dScaleFactor);
To convert EMF file to PDF just call PlayMetaFile method. PDF->PlayMetaFile(emfFile, 0, 0, dScaleFactor, dScaleFactor);
PDF->SaveToFile("PlayMetafile.pdf", true);
You can find a full example bellow. You may also download a MS Visual Studio project with this example here.
|



Example