PDF Creator Pilot documentation |
Download CHM version of this manual. |
|
![]() ![]() Collapse AllFirst, import the PDF Creator Pilot library into your project. #import "c:\\...\\PDFCreatorPilot.dll" // enter path here using namespace PDFCreatorPilotLib; Then 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;
}
Call the SetLicenseData method and adjust properties as needed. Load an EMF file so you can access its width, height, and resolution properties. Calculate the scaleFactor. This value is needed to properly draw the EMF file to the 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);
Then to convert the EMF file to a PDF, call the 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