Font errors

Skip Navigation LinksHome  /  Support  /  Forums  /  DynamicPDF Merger for .NET (v4)  /  Font errors

DynamicPDF Merger for .NET (v4) Forum

 Jan 07 2010 6:13 PM
Issue:

I experience the following error when I open a PDF document produced by dynamicPDF in Acrobat Reader 8.1.3:

"Cannot extract the embedded font 'JIHLCH+Wingdings2'. Some characters may not display or print correctly."

The font name can vary depending on the "source" file that is used. In this particular example, it is "Wingdings2", but most commonly, I have "PalatinoLinotype,Italic" as the problem font. As Palatino" is the corporate font, much of the document uses this.

This problem is intermittant meaning that sometimes when processing the "same" input details, the outputted PDF is not corrupt. Also, I use the same process for many documents and this problem seems to only occur for some.

I have found that this issue most often occurs when I add a FontFamily to a FormattedTextArea that is merged into the document (as described below). When this functionality is not used and the build-in FontFamily.Helvetica is used, I rarely see a corrupt document.

I have a sample of the "source" template and a corrupt customized document if this will assist.

I am using version 4.0.0.0 (Server Edition Build 60523). I have similar issues with version 5.1.2.20 (build 14406).



Usage:

I have a number of PDF files that are my "source" template files. My process uses dynamicPDF to load a source file, customize it for a particular customer by adding various PageElements to the document and then saving the customized PDF file.

The "source" files are created from existing word documents that have been converted to PDF documents using Adobe Acrobat 8 Professional. These word documents contain text that uses the standard Palatino and Wingdings fonts that come with Windows XP. My process does the following:

1. Load the "source" PDF file into the merger:
                        ceTe.DynamicPDF.Merger.PdfDocument pdfTemplate = new ceTe.DynamicPDF.Merger.PdfDocument(GetBytesFromFile(_staticPdfFile.FileLocation));
                        ceTe.DynamicPDF.Merger.MergeOptions mergeOptions = new ceTe.DynamicPDF.Merger.MergeOptions(false);
                        _staticPdfFile.PdfDocument = new ceTe.DynamicPDF.Merger.MergeDocument(pdfTemplate, mergeOptions);

                        (please note that "static" in this case is just terminology in the code and does not refer to a static c# object)
                        
2. "Merges" a number of PageElements into the document on various pages. These are FormattedTextAreas and Images. The FormattedTextArea makes use of an additional font (to meet the corporate standard) as follows:
                                ceTe.DynamicPDF.Text.TrueTypeFont palatinoLinotypeRegular = new ceTe.DynamicPDF.Text.TrueTypeFont("pala.ttf");
                                ceTe.DynamicPDF.Text.TrueTypeFont palatinoLinotypeBold = new ceTe.DynamicPDF.Text.TrueTypeFont("palab.ttf");
                                ceTe.DynamicPDF.Text.TrueTypeFont palatinoLinotypeItalic = new ceTe.DynamicPDF.Text.TrueTypeFont("palai.ttf");
                                ceTe.DynamicPDF.Text.TrueTypeFont palatinoLinotypeBoldItalic = new ceTe.DynamicPDF.Text.TrueTypeFont("palabi.ttf");

                                ceTe.DynamicPDF.FontFamily palatinoLinotypeFontFamily = new ceTe.DynamicPDF.FontFamily("Palatino Linotype", palatinoLinotypeRegular, palatinoLinotypeBold, palatinoLinotypeItalic, palatinoLinotypeBoldItalic);
{snip}
                                ceTe.DynamicPDF.PageElements.FormattedTextAreaStyle formattedTextAreaStyle = new ceTe.DynamicPDF.PageElements.FormattedTextAreaStyle(palatinoLinotypeFontFamily, _pdfFormattedTextAreaPageElement.DefaultFontSize, false);
{snip}
                                ceTe.DynamicPDF.PageElements.FormattedTextArea formattedTextArea = new ceTe.DynamicPDF.PageElements.FormattedTextArea(text, x, y, width, height, formattedTextAreaStyle);
{snip}
                                formattedTextArea.FontFaces.Add(palatinoLinotypeFontFamily);
{snip}
                                _dynamicPdfFile.PdfDocument.Pages[_currentPage].Elements.Add(formattedTextArea);
                                

3. Outputs the the result to a memory stream (for a later email process):
                        System.IO.MemoryStream memoryStream = new System.IO.MemoryStream();
                        _staticPdfFile.PdfDocument.Draw(memoryStream);



More Information:

I notice the following on the Fonts tab of Document Properties in Adobe Reader when the error occurs:

1. The "source" template PDF document lists Wingdings2 with the following details:
Wingdings2 (Embedded Subset)
Type: TrueType (CID)
Encoding: Identity-H

2. The "customized" document (after the process described above) lists Wingdings2 with the following details:
Wingdings2
Type: TrueType (CID)
Encoding: Identity-H
Actual Font: Unknown

It seems to me that something is happening to the Wingdings2 (and often Palatino) font in the PDF document as part of the processing by the dynamicPDF object.

Thank you for your assistance
 Jan 08 2010 5:04 AM
Posted by a ceTe Software moderator
Hello,

Can you please send over the source PDF document you are using which has the fonts embedded and the code you are using to add the palatino font along with the font file to our Support Team so that they can look into it further?

Thanks,
ceTe Software Support Team.
 Apr 14 2021 6:37 PM
if you are using a formatted text area, make sure your add the facename  before you add the area. if you need to modify the area parameters after creating the formatted text area, make sure you register the facenames  first. Dynamic pdf is pretty touchy when you try to use open type fonts, so you need to set it up just right..
                Font ceteFont = findFont(theFirstFont);
                        FontFamily fam = findFontFamily(theFirstFont);
           // need to list all other fonts and set them up here before we build the text area...
            // add a routine that defines the other fonts for this formatted Text area....

                        FormattedTextAreaStyle style = new FormattedTextAreaStyle(fam, theBiggestPointSize, true);
                        style.Line.LeadingType = LineLeadingType.Exactly;
                        style.Line.Leading = theLeading;
        
                        FormattedTextArea area = new FormattedTextArea(theStringToPrintX,
                                convertX(cursorX), 0, convertX((float)theWidth), 0, style);

            if (PDFDudeDocument.UsedTrueTypesInThisString[0] == true)
            {

                area.FontFaces.Add(PDFDudeDocument.wingDingsFamily);
            }

            if (PDFDudeDocument.UsedTrueTypesInThisString[1] == true)
            {
               area.FontFaces.Add(PDFDudeDocument.wingDing2Family);
            }

            if (PDFDudeDocument.UsedTrueTypesInThisString[2] == true)
            {
                area.FontFaces.Add(PDFDudeDocument.CooperFamily);
            }

            if (PDFDudeDocument.UsedTrueTypesInThisString[3] == true)
            {
          
                area.FontFaces.Add(PDFDudeDocument.CenturyFamily);
            }
                        float trueHeight = area.GetRequiredHeight();

                        area.Y = convertYForRaggedEdge(cursorY, trueHeight) - theLeading + raggedEdgeAdjustment; //testing
                        area.Height = trueHeight;
    
                        myPage.Elements.Add(area);

All times are US Eastern Standard time. The time now is 9:11 AM.