DynaPDF Manual - Page 32

Previous Page 31   Index   Next Page 33

Language Bindings
Page 32 of 839
If possible, then use the dynapdf.dll instead. This library requires no additional dependencies to
enable 64 bit file support.
If you want to use DynaPDF with a C++ project, add the line "using namespace DynaPDF;" after
including the header file dynapdf.h.
The usage in C is essentially the same as in C++, with the exception that the namespace
DynaPDF must not be declared.
A PDF instance can be used to create an arbitrary count of PDF files. All used resources are
automatically freed when the PDF file is closed (except when the PDF file was created in
memory). To improve processing speed, use one instance as long as possible.
Most examples are written in C or C++ which can directly be used with a Embarcadero or
Microsoft Compiler.
Example (C++):
// Include the DynaPDF header file (change the path if necessary)
#include "dynapdf.h"
// All data types and functions are declared in the namespace DynaPDF.
using namespace DynaPDF;
// First, we declare an error callback function that is called by
// DynaPDF if an error occurred.
SI32 PDF_CALL PDFError(const void* Data, SI32 ErrCode, const char*
ErrMessage, SI32 ErrType)
printf("%s\n", ErrMessage);
return 0; // Any other return value break processing
// Place a button on the form and double click on it. Add the
// code to the function.
int main(int argc, char* argv[])
void* pdf = pdfNewPDF(); // Create a new PDF instance
if (!pdf) return 2; // Out of memory?
// Set the error callback first
pdfSetOnErrorProc(pdf, NULL, PDFError);
pdfCreateNewPDF(pdf, "c:/myfirst.pdf");
pdfSetPageCoords(pdf, pcTopDown); // We use top-down coordinates
pdfSetFont(pdf, "Arial", fsItalic, 40.0, true, cp1252);
pdfWriteFText(pdf, taCenter, "My first C++ output!");
pdfCloseFile(pdf); // Close the file and free all used resources
pdfDeletePDF(pdf); // Do not forget to delete the PDF instance

Previous topic: Microsoft Visual C++

Next topic: Microsoft Visual Basic 6.0, Exception handling in Visual Basic