DynaPDF Manual - Page 218

Previous Page 217   Index   Next Page 219

Function Reference
Page 218 of 860
Remarks:
The return value of the function must not be ignored. If a required ICC profile will not be added to
the file, the resulting PDF file will not be compatible to PDF/A! The PDF file must be closed with
CloseFile(). The usage of CloseFileEx() is prohibited because PDF/A files must not be encrypted.
CheckConformance() can be called after the entire document was fully created. You must not call
the function multiple times on the same document in memory!
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 claims that this feature is not available in 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 3.0.49.148 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.
switch(Type)
{
case ictGray:
return pdfReplaceICCProfile(Data, ColorSpace,
"c:/Windows/System32/spool/drivers/color/gray_gamma2.2.icm");
case ictRGB:
return pdfReplaceICCProfile(Data, ColorSpace,
"c:/Windows/System32/spool/drivers/color/sRGB Color Space Profile.icm");
case ictCMYK:
return pdfReplaceICCProfile(Data, ColorSpace,
"c:/Windows/System32/spool/drivers/color/EuropeISOCoatedFOGRA27.icc");
default: return -1;
}
}
 

Previous topic: Return values

Next topic: CheckFieldNames, CircleAnnot