DynaPDF Manual - Page 205

Previous Page 204   Index   Next Page 206

Function Reference
Page 205 of 839
// 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;
}
}
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)
{
pdfFreePDF(PDF);
return -1;
}
pdfImportPDFFile(PDF, 1, 1.0, 1.0);
switch(pdfCheckConformance(PDF, ctPDFA_1b_2005, coDefault_PDFA_1,
PDF, // We need the instance pointer in the callback functions
pdf_OnFontNotFount,
pdf_OnReplaceICCProfile))
{
case 1: pdfAddRenderingIntent(PDF, m_RGBProfile); break;
case 2: pdfAddRenderingIntent(PDF, m_CMYKProfile); break;
case 3: pdfAddRenderingIntent(PDF, m_GrayProfile); break;
default: break;
}
// Still a PDF file in memory?
if (pdfHaveOpenDoc(PDF))
{
if (!pdfOpenOutputFile(PDF, OutFileName))
 

Previous topic: Return values

Next topic: CheckFieldNames