Print Page | Close Window

Visual C++ Starter example code

Printed From: Debenu Quick PDF Library - PDF SDK Community Forum
Category: For Users of the Library
Forum Name: Sample Code
Forum Description: Share Debenu Quick PDF Library sample code with other forum members
URL: http://www.quickpdf.org/forum/forum_posts.asp?TID=535
Printed Date: 22 Nov 24 at 6:48PM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: Visual C++ Starter example code
Posted By: bobhall106
Subject: Visual C++ Starter example code
Date Posted: 17 Oct 06 at 7:24AM

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

}




Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.01 - http://www.webwizforums.com
Copyright ©2001-2014 Web Wiz Ltd. - http://www.webwiz.co.uk