I am attempting to get a list of embedded fonts in an imported PDF. I can pull in non-embedded fonts just fine, however, if there is an embedded font, it fails with a NullReferenceException. This failure occurs on line 3 and with any PDF I attempt to get a list of fonts for if they are embedded.
My code:
- Code: Select all
Dim PDF As PdfDocument = New PdfDocument
PDF.LoadFromFile("C:\Sample.pdf")
Dim Fonts As PdfUsedFont() = PDF.UsedFonts()
Dim ListOfFonts As New List(Of String)
For Each Font As PdfUsedFont In Fonts
ListOfFonts.Add(Font.Name + " - " + Font.Style.ToString() + " - " + Font.Type.ToString())
Next
Any advice would be greatly appreciated!