DynaPDF Manual - Page 578

Previous Page 577   Index   Next Page 579

Function Reference
Page 578 of 839
return 0;
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, 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;

Previous topic: Damaged PDF files

Next topic: OpenOutputFile