Xojo Conferences

DynaPDF Manual - Page 59

Previous Page 58   Index   Next Page 60

PDF/A and PDF/AX Compatibility
Page 59 of 766
Example (C++):
// Error callback function.
SI32 PDF_CALL PDFError(const void* Data, SI32 ErrCode, const char*
ErrMessage, SI32 ErrType)
printf("%s\n", ErrMessage);
return -1; // We break processing if an error occurs
int main(int argc, char* argv[])
void* pdf = pdfNewPDF();
if (!pdf) return 2; // Out of memory?
pdfSetOnErrorProc(pdf, NULL, (void*)PDFError);
pdfCreateNewPDF(pdf, "c:/cppout.pdf");
pdfSetDocInfo(pdf, diCreator, "C++ Example project");
pdfSetDocInfo(pdf, diTitle, "PDF/X Compatibility");
// Just set the trim box to the same value as the media box if no
// better value is known.
TPDFRect b;
pdfGetBBox(pdf, pbMediaBox, b);
pdfSetBBox(pdf, pbTrimBox, b.Left, b.Bottom, b.Right, b.Top);
// The font must be embedded (this should always be the case)
pdfSetFont(pdf, "Arial", fsItalic, 20.0, true, cp1252);
pdfSetColorSpace(pdf, csDeviceCMYK);
pdfSetFillColor(pdf, PDF_CMYK(0, 0, 0, 255));
pdfWriteFText(pdf, taCenter,
"A very simple PDF/X compliant PDF file...");
// The PDF version should be set before the file is closed because
// it can be changed when importing a PDF file.
pdfSetPDFVersion(pdf, pvPDFX1a_2001);
return 0;

Previous topic: PDF/X

Next topic: PDF/A