Xojo Conferences

DynaPDF Manual - Page 256

Previous Page 255   Index   Next Page 257

Function Reference
Page 256 of 766
pdfDeletePDF(pdf); // Delete the PDF instance
return 0;
Example 2: Usage of OpenOutputFile()
int main(int argc, char* argv[])
PPDF* pdf = pdfNewPDF();
if (!pdf) return 2; // Out of memory?
// No need to check return values.
pdfSetOnErrorProc(pdf, NULL, (void*)PDFError);
pdfSetDocInfo(pdf, diSubject, "Usage of OpenOutputFile()...");
pdfCreateNewPDF(pdf, NULL);
pdfSetFont(pdf, "Arial", fsItalic, 40.0, true, cp1252);
pdfWriteFText(pdf, taCenter, "We use OpenOutputFile() now...");
// No fatal error occurred?
if (pdfHaveOpenDoc(pdf))
// OK, now we can open the output file.
/* Note that the function can also be called in a while statement
* e.g. to display a file open dialog if the file could not be
* opened...
if (!pdfOpenOutputFile(pdf, "c:/test.pdf"))
printf("Cannot open output file!\n");
return -1;
if (pdfCloseFile(pdf))
printf("PDF file successfully created!\n");

Previous topic: CreateNewPDF

Next topic: CreateOCG