Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to parse pdf due to font issue #823

Open
romanimm opened this issue Apr 24, 2024 · 0 comments
Open

Unable to parse pdf due to font issue #823

romanimm opened this issue Apr 24, 2024 · 0 comments

Comments

@romanimm
Copy link

I've stumbled upon this pdf, which throws an InvalidFontFormatException up on calling document.GetPages() or GetPage(x).

UglyToad.PdfPig.Fonts.InvalidFontFormatException
No font descriptor indirect reference found in the TrueType font: <BaseFont, /ZAYDXJ YogaSansforLUKB-Light>, <Encoding, /WinAnsiEncoding>, <FirstChar, 32>, <FontDescriptor, 3170 0>, <LastChar, 150>, <Subtype, /TrueType>, <ToUnicode, 168 0>, <Type, /Font>, <Widths, [ 230, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 234, 0, 500, 500, 500, 500, 0, 0, 500, 500, 0, 500, 0, 0, 0, 0, 0, 0, 0, 631, 544, 0, 679, 0, 518, 0, 0, 0, 275, 0, 0, 0, 0, 0, 0, 0, 0, 476, 0, 674, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 429, 0, 0, 0, 464, 0, 0, 532, 238, 0, 477, 0, 780, 0, 525, 0, 0, 351, 387, 332, 518, 0, 0, 0, 0, 434, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 450 ]>.
   at UglyToad.PdfPig.PdfFonts.Parser.FontDictionaryAccessHelper.GetFontDescriptor(IPdfTokenScanner pdfScanner, DictionaryToken dictionary)
   at UglyToad.PdfPig.PdfFonts.Parser.Handlers.TrueTypeFontHandler.Generate(DictionaryToken dictionary)
   at UglyToad.PdfPig.PdfFonts.FontFactory.Get(DictionaryToken dictionary)
   at UglyToad.PdfPig.Content.ResourceStore.LoadFontDictionary(DictionaryToken fontDictionary)
   at UglyToad.PdfPig.Content.ResourceStore.LoadResourceDictionary(DictionaryToken resourceDictionary)
   at UglyToad.PdfPig.Content.BasePageFactory`1.Create(Int32 number, DictionaryToken dictionary, PageTreeMembers pageTreeMembers, NamedDestinations namedDestinations)
   at UglyToad.PdfPig.Content.Pages.GetPage[TPage](IPageFactory`1 pageFactory, Int32 pageNumber, NamedDestinations namedDestinations, ParsingOptions parsingOptions)
   at UglyToad.PdfPig.Content.Pages.GetPage(Int32 pageNumber, NamedDestinations namedDestinations, ParsingOptions parsingOptions)
   at UglyToad.PdfPig.PdfDocument.GetPage(Int32 pageNumber)
   at UglyToad.PdfPig.PdfDocument.GetPages() MoveNext()

I've tried with different ParsingOptions:

  • SkipMissingFonts = true gives a null pointer exception
  • UseLenientParsing = true has no effect

Log:

Debug Found the first cross reference table or stream at 2079366.
Debug Reading cross reference table or stream at 2079366.
Debug Element was cross reference table.
Debug Reading cross reference table or stream at 1971977.
Debug Element was cross reference table.
Debug Reading cross reference table or stream at 1966160.
Debug Element was cross reference table.
Debug Reading cross reference table or stream at 116.
Debug Element was cross reference table.
Debug Cross reference table contained reference to stream. Reading the stream.
Debug Reading cross reference table or stream at 1887879.
Debug Element was cross reference table.
Debug Accessing page 1.

Tested with 0.1.8 and 0.1.9-alpha-20240419-1ef2e on windows an linux (alpine).

BobLd added a commit to BobLd/PdfPig that referenced this issue May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant