- Home
- Testimonials
- Purchase
- Developer Tools
- Desktop Utilities
- Download
- Support
- Blog
- Company
CONTACT US: SUPPORT@BYTESCOUT.COM or SUBMIT ONLINE FORM
SALES: +1.888.919.6637
You can download the source code of this example here: pdfdocscout_vc.zip
This tutorial will teach you how to create simple PDF document from VC++ using PDFDoc Scout library.
1) Install PDFDoc Scout library on your computer and run Visual C++







// HelloWorld.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#import "PDFDocScout.tlb"
using namespace PDFDocScout;
int main(int argc, char* argv[])
{
// initialize OLE
HRESULT hr = CoInitialize(NULL);
// check for errors
if (FAILED(hr)) {
MessageBox(0,"OLE initialization errp","error",MB_OK);
return -1;
}
// declare PDFDoc object
IPDFDocument* PDFDoc = NULL;
CLSID clsid;
// get inuque ID for IPDFDocument interface
hr = CLSIDFromProgID(OLESTR("PDFDocScout.PDFDocument"), &clsid);
// check for errors
if (FAILED(hr)) {
MessageBox(0,"Can't get CLSID for IPDFDocument interface","error",MB_OK);
goto Uninit;
};
// create PDFDoc object
hr = CoCreateInstance(clsid, NULL, CLSCTX_ALL,__uuidof(IPDFDocument), (LPVOID*)&PDFDoc);
// check for errors
if (FAILED(hr)) {
MessageBox(0,"Can't create PDFDoc object","error",MB_OK);
goto Uninit;
}
// initialize library
PDFDoc->InitLibrary("demo", "demo");
// set output PDF filename
PDFDoc->OutputFileName = "c:\\HelloWorld.pdf";
// set library to automatically open generated PDF document in default PDF viewer application
PDFDoc->AutoOpenGeneratedPDF = true;
// starts PDF documen generation
PDFDoc->BeginDocument();
// add text to current page at (100,100) with 15 degrees rotation
PDFDoc->AddText("Hello, World!", 100, 100, 15);
PDFDoc->EndDocument(); // close generated PDF document
// release PDFDoc object
PDFDoc->Release();
// uninitialize OLE libraries
Uninit:
CoUninitialize();
return 0;
}
This code will generate PDF document file that will be saved as "c:\HelloWorld.PDF" file

Tutorials: