Xojo Conferences

DynaPDF Manual - Page 525

Previous Page 524   Index   Next Page 526

Function Reference
Page 525 of 766
int main(int argc, char* argv[])
char outFile[] = "cout.pdf";
void* pdf = pdfNewPDF(); // Create a new PDF instance
if (!pdf) return -2; // Out of memory?
pdfSetOnErrorProc(pdf, NULL, (void*)PDFError);
// The output file is opened later...
pdfCreateNewPDF(pdf, NULL);
// No need to convert pages to templates. See SetImportFlags() for
// further information.
pdfSetImportFlags(pdf, ifImportAll | ifImportAsPage);
pdfSetImportFlags2(pdf, if2UseProxy); // Reduce the memory usage
pdfOpenImportFile(pdf, "test.pdf", ptOwner, NULL);
pdfImportPDFFile(pdf, 1, 1.0, 1.0);
// No fatal error occurred?
if (pdfHaveOpenDoc(pdf))
// OK, now we can open the output file. The function can be called
// in a while statement, e.g. to display a file open dialog.
if (!pdfOpenOutputFile(pdf, outFile))
return -1;
// We encrypt the file, low-resolution printing should be allowed
if (pdfCloseFileEx(pdf,NULL,"%3Fc&",kl128bit, rsDenyAll & ~rsPrint))
printf("PDF file \"%s\" successfully created!\n", outFile);
ShellExecute(0, "open", outFile, NULL, NULL, SW_SHOWMAXIMIZED);
pdfDeletePDF(pdf); // Do not forget to delete the PDF instance
return 0;
LBOOL pdfOpenOutputFile(
const PPDF* IPDF,
// Instance pointer
const char* OutPDF) // Output file name
The function opens the output file into which the PDF file should be written. The PDF file must be
created in memory if this function should be used. This is the case if the output file name is set to
NULL or to an empty string in CreateNewPDF().

Previous topic: Damaged PDF files

Next topic: OpenOutputFileEncrypted