We are trying to detect the text ‘PROFILO AUTORI’ as Bold and ‘Il controllo legale’ as Italic in the attached PDF but the ‘FontWeight’ & ‘ItalicAngle’ value always returning ‘Null’ or Zero. Please let me know how to achieve this through ‘CharIterator’.
Sample Code Taken from this Forum:
Dim italicangle As Double = 0
Dim BoldValue As Double = 0
Dim font_desc As Object = tfont.GetDescriptor()
If font_desc IsNot Nothing Then
Dim angle As Object = font_desc.FindObj(“ItalicAngle”)
If angle IsNot Nothing Then
italicangle = angle.GetNumber()
italicangle = 0
Dim tBold As Object = font_desc.FindObj(“FontWeight”)
If tBold IsNot Nothing Then
BoldValue = tBold.GetNumber()
BoldValue = 0
Error_page-001.pdf (66.8 KB)
These other forum posts go into more detail. Essentially there is no easy reliable way.
You could also check FontDescriptor.ItalicAngle, however just like the flags and font weight, it is often not reliable.
It might better if you explained why you want to find bold/italic fonts?
We are trying to achieve the automatic creation of bookmark and replacing text inside the bold or italic format from the given pdf. Is there any way to identify the format information through character glyph path?
Going through the glyphs paths to determine boldness and italics is probably even harder. Typically font glyphs are filled, not stroked, so the boldness comes from how far apart the paths are, and not from a single stoke thickness value.
What do you mean by “replacing text”? This can mean a lot of things, some of which are again, are difficult to do.