Free Support Forum - aspose.com

Incorrect Font detection

Hello again,

I believe we have found another bug. This bug consists of a non-embeded font being detected as a different font improperly. <!–[if gte mso 9]>
<w:WordDocument>
<w:View>Normal</w:View>
<w:Zoom>0</w:Zoom>
<w:TrackMoves/>
<w:TrackFormatting/>
<w:PunctuationKerning/>
<w:ValidateAgainstSchemas/>
<w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
<w:IgnoreMixedContent>false</w:IgnoreMixedContent>
<w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
<w:DoNotPromoteQF/>
<w:LidThemeOther>EN-US</w:LidThemeOther>
<w:LidThemeAsian>X-NONE</w:LidThemeAsian>
<w:LidThemeComplexScript>X-NONE</w:LidThemeComplexScript>
<w:Compatibility>
<w:BreakWrappedTables/>
<w:SnapToGridInCell/>
<w:WrapTextWithPunct/>
<w:UseAsianBreakRules/>
<w:DontGrowAutofit/>
<w:SplitPgBreakAndParaMark/>
<w:DontVertAlignCellWithSp/>
<w:DontBreakConstrainedForcedTables/>
<w:DontVertAlignInTxbx/>
<w:Word11KerningPairs/>
<w:CachedColBalance/>
</w:Compatibility>
<w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
<m:mathPr>
<m:mathFont m:val=“Cambria Math”/>
<m:brkBin m:val=“before”/>
<m:brkBinSub m:val="–"/>
<m:smallFrac m:val=“off”/>
<m:dispDef/>
<m:lMargin m:val=“0”/>
<m:rMargin m:val=“0”/>
<m:defJc m:val=“centerGroup”/>
<m:wrapIndent m:val=“1440”/>
<m:intLim m:val=“subSup”/>
<m:naryLim m:val=“undOvr”/>
</m:mathPr></w:WordDocument>
<![endif]–><!–[if gte mso 10]>

/* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:"Times New Roman"; mso-fareast-theme-font:minor-fareast; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi;}

<![endif]–>

Attached is a file which I know has one non-embedded font (Garamond-Bold). I know that because I took a clean file and removed that font. The PTO website is also reporting that as the font which is a problem I try to upload it.

But Aspose is reporting the missing font as Helvetica-Bold.

The method I use to return fonts that are not embedded is as follows. I also verified the return of Aspose by picking up the incorrect font during a debug.

public string BadFontsNotEmbedded
        {
            get
            {
                string ret = "";
                TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber();
                pdfDocument.Pages.Accept(textFragmentAbsorber);
                TextFragmentCollection textFragmentCollection = textFragmentAbsorber.TextFragments;
                foreach (TextFragment textFragment in textFragmentCollection)
                {
                    if (!textFragment.TextState.Font.IsEmbedded)
                        if(!ret.Contains(textFragment.TextState.Font.FontName))
                            ret = ret + textFragment.TextState.Font.FontName + ",";
                }
                try { return ret.Remove(ret.Length - 1); }
                catch { return null; }
            }
        }
Now here is some interesting additional information. Using Aspose I created a PDF and used
s1.TextInfo.FontName = "Garamond Bold";

Notice the absence of the '-' char. This did work properly.
When I use Adobe Acrobat to edit the PDF, the non-embeded font is displayed as 'Garamond-Bold'

So to summarize, I believe Aspose is reporting the incorrect font, where both the PTO and Adobe are picking up
'Garamond-Bold'. Attached is the used form.

PS. sorry for the funny formatting, the post-box here is not cooperating with me today.

Thanks


Hi,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for sharing the template file and sample code.

We will further investigate your reported issue and get back to you soon.

Sorry for the inconvenience,

jrocke:
Hello again,

I believe we have found another bug. This bug consists of a non-embeded font being detected as a different font improperly. <!–[if gte mso 9]>
<w:WordDocument>
<w:View>Normal</w:View>
<w:Zoom>0</w:Zoom>
<w:TrackMoves/>
<w:TrackFormatting/>
<w:PunctuationKerning/>
<w:ValidateAgainstSchemas/>
<w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
<w:IgnoreMixedContent>false</w:IgnoreMixedContent>
<w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
<w:DoNotPromoteQF/>
<w:LidThemeOther>EN-US</w:LidThemeOther>
<w:LidThemeAsian>X-NONE</w:LidThemeAsian>
<w:LidThemeComplexScript>X-NONE</w:LidThemeComplexScript>
<w:Compatibility>
<w:BreakWrappedTables/>
<w:SnapToGridInCell/>
<w:WrapTextWithPunct/>
<w:UseAsianBreakRules/>
<w:DontGrowAutofit/>
<w:SplitPgBreakAndParaMark/>
<w:DontVertAlignCellWithSp/>
<w:DontBreakConstrainedForcedTables/>
<w:DontVertAlignInTxbx/>
<w:Word11KerningPairs/>
<w:CachedColBalance/>
</w:Compatibility>
<w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
<m:mathPr>
<m:mathFont m:val=“Cambria Math”/>
<m:brkBin m:val=“before”/>
<m:brkBinSub m:val="–"/>
<m:smallFrac m:val=“off”/>
<m:dispDef/>
<m:lMargin m:val=“0”/>
<m:rMargin m:val=“0”/>
<m:defJc m:val=“centerGroup”/>
<m:wrapIndent m:val=“1440”/>
<m:intLim m:val=“subSup”/>
<m:naryLim m:val=“undOvr”/>
</m:mathPr></w:WordDocument>
<![endif]–><!–[if gte mso 10]> /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:"Times New Roman"; mso-fareast-theme-font:minor-fareast; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi;}

<![endif]–>

Attached is a file which I know has one non-embedded font (Garamond-Bold). I know that because I took a clean file and removed that font. The PTO website is also reporting that as the font which is a problem I try to upload it.

But Aspose is reporting the missing font as Helvetica-Bold.

The method I use to return fonts that are not embedded is as follows. I also verified the return of Aspose by picking up the incorrect font during a debug.

public string BadFontsNotEmbedded
        {
            get
            {
                string ret = "";
                TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber();
                pdfDocument.Pages.Accept(textFragmentAbsorber);
                TextFragmentCollection textFragmentCollection = textFragmentAbsorber.TextFragments;
                foreach (TextFragment textFragment in textFragmentCollection)
                {
                    if (!textFragment.TextState.Font.IsEmbedded)
                        if(!ret.Contains(textFragment.TextState.Font.FontName))
                            ret = ret + textFragment.TextState.Font.FontName + ",";
                }
                try { return ret.Remove(ret.Length - 1); }
                catch { return null; }
            }
        }


Hi,

Thanks for using our products.

I have managed to reproduce the same problem that Aspose.Pdf for .NET is always returning Helvetica-Bold font name whereas the source PDF file contains
Garamond-Bold, Helvetica, Helvetica-Bold, Times-Roman and ZZapfDingbats fonts which are not embedded. For the sake of correction, I have logged this problem as PDFNEWNET-30782
in our issue tracking system. We will further look into the details of this problem and will keep you updated on the status of correction. We apologize for this inconvenience.

jrocke:
Now here is some interesting additional information. Using Aspose I created a PDF and used
s1.TextInfo.FontName = "Garamond Bold";

Notice the absence of the '-' char. This did work properly.
When I use Adobe Acrobat to edit the PDF, the non-embeded font is displayed as 'Garamond-Bold'

So to summarize, I believe Aspose is reporting the incorrect font, where both the PTO and Adobe are picking up
'Garamond-Bold'. Attached is the used form


I have tested the scenario using following code snippet with Aspose.Pdf for .NET 6.2.0 and as per my observations, I am able to notice that when using "Garamond Bold" string to address the font name,
it properly being used and I am unable to notice any issue. In fact I have Garamond.TTC (True Type Fonts collection) and it contains Bold, Italic and Regular font as these fonts share many glyphs in common.
However in resultant PDF, the font name is being referred as Garamond-Bold. Do you think Aspose.Pdf for .NET should accept font name as Garamond-Bold ? (Currently I have observed
that if we enter font name as Garamond-Bold, an error is being displayed). Please share your feedback. We are sorry for your inconvenience.