Xojo Conferences

DynaPDF Manual - Page 180

Previous Page 179   Index   Next Page 181

Function Reference
Page 180 of 770
Example (C++):
// This example converts an arbitrary PDF file to PDF/A. In order to execute this code with a licensed
// version of DynaPDF, you need also a license of the PDF/A Extension. If you don't have such a
// license then don't set a license key! Otherwise the function would return with the error that this
// feature is not available with your license...
// Warnings and errors are passed to the error callback function. The messages should normally be
// stored in an error log.
SI32 PDF_CALL PDFError(const void* Data, SI32 ErrCode, const char* ErrMessage, SI32 ErrType)
printf("%s\n", ErrMessage);
return 0;
// This function will be called when a non-embedded font was not found on the system.
// DynaPDF uses already an internal mapping table for the most known good matches. However,
// some drivers write invalid font names into the file, e.g. when the PDF file was created
// from a PCL recourse. For such cases you can create your own mapping table or a default
// font.
// Since DynaPDF the function is no longer called for the 14 PDF standard fonts
// because DynaPDF can now create Type3 versions of these fonts if no suitable system font
// is available.
SI32 PDF_CALL pdf_OnFontNotFount(const void* Data, const void* PDFFont,
const char* FontName, SI32 Style, SI32 StdFontIndex, LBOOL IsSymbolFont)
// Here you could use your own mapping table.
// In this example we replace the font simply with Arial
if (WeightFromStyle(Style) < 500)
// Only the weights 500 and 700 of Arial are installed
// by default. If you have also light variants then it is
// not required to change the style.
Style &= 0xF;
Style |= fsRegular;
return pdfReplaceFont(Data, PDFFont, "Arial", Style, true);
SI32 PDF_CALL pdf_OnReplaceICCProfile(const void* Data, TICCProfileType Type, SI32 ColorSpace)
// The ICC profiles to be used should normally be configured by the user.
case ictGray:
return pdfReplaceICCProfile(Data, ColorSpace,
case ictRGB:
return pdfReplaceICCProfile(Data, ColorSpace,
"c:/Windows/System32/spool/drivers/color/sRGB Color Space Profile.icm");
case ictCMYK:
return pdfReplaceICCProfile(Data, ColorSpace,
default: return -1;
SI32 PDFToPDFA(const void* PDF, const char* InFileName, const char* OutFileName)
pdfCreateNewPDF(PDF, NULL);
// Don't override the producer with "DynaPDF 4.0..."
pdfSetDocInfo(PDF, diProducer, NULL);
// The flag ifPrepareForPDFA is required!
pdfSetImportFlags(PDF,ifImportAll | ifImportAsPage | ifPrepareForPDFA);
// Optional but recommended to reduce the memory usage
pdfSetImportFlags2(PDF, if2UseProxy);
if (pdfOpenImportFile(PDF, InFileName, ptOpen, NULL) < 0)
return -1;

Previous topic: Return values

Next topic: CheckFieldNames