This is some simple COM code to get you started in Visual C++ using the ActiveX part of Quick PDF. The code opens an existing file adds a footer text to each page and then saves the file to a different PDF. Enjoy. Check your hr return codes for errors in real life.
//import the dll guids and interface by dll name in project dir. This should add the interface to Intellisense and you can code from there
#import "ISED.dll" named_guids raw_interfaces_only
void AddPDFFooter()
{
//dont forget to call ::CoInitialize(NULL); in your app init
CComPtr<iSED::IQuickPDF> spPDF; //smart pointer to pdf object
//create the COM object
HRESULT hr = CoCreateInstance( iSED::CLSID_QuickPDF, NULL, CLSCTX_INPROC_SERVER, iSED::IID_IQuickPDF, ( void**)&spPDF);
//add your key code here
CComBSTR key="add your key code here"; //change me!! long rtn=0;//general return values
hr=spPDF->UnlockKey(key,&rtn);//unlock the product
CComBSTR file="c:\\input.pdf";//change for your input file
hr=spPDF->LoadFromFile(file,&rtn); //load a local file
long pages=0;
spPDF->PageCount(&pages); //count the pages in the document
CComBSTR footer="testing 123"; //this is the footer text
for(int page=0;page<pages+1;page++)//for each page of the document
{
hr=spPDF->SelectPage(page,&rtn); //select each page in turn
hr=spPDF->SetTextSize(6,&rtn); //set the font size (6pt here)
hr=spPDF->DrawText(10, 10, footer,&rtn); //draw the footer text
}
CComBSTR output="C:\\output.pdf"; //temp output path
hr= spPDF->SaveToFile(output,&rtn); //save the file to disk
//dont forget to call ::CoUninitialize(); in your app closure
}
|