PdfPig
PdfPig copied to clipboard
System.OverflowException Arithmetic operation resulted in an overflow
Hola,
We scan PDF text and parse some data from it. The PDF provider randomly changed their font and now we keep getting this exception when the font type in a PDF is Hervetica or some similar one. Not sure what to do now.. I have attached the PDF that is failing.
System.OverflowException: Arithmetic operation resulted in an overflow. at UglyToad.PdfPig.Fonts.TrueType.Tables.CMapSubTables.ByteEncodingCMapTable.Load(TrueTypeDataBytes data, TrueTypeCMapPlatform platformId, UInt16 encodingId) at UglyToad.PdfPig.Fonts.TrueType.Parser.CMapTableParser.Parse(TrueTypeHeaderTable header, TrueTypeDataBytes data, Builder register) at UglyToad.PdfPig.Fonts.TrueType.Parser.TableParser.Parse[T](TrueTypeHeaderTable table, TrueTypeDataBytes data, Builder register) at UglyToad.PdfPig.Fonts.TrueType.Parser.TrueTypeFontParser.OptionallyParseTables(IReadOnlyDictionary2 tables, TrueTypeDataBytes data, Builder tableRegister) at UglyToad.PdfPig.Fonts.TrueType.Parser.TrueTypeFontParser.ParseTables(Single version, IReadOnlyDictionary2 tables, TrueTypeDataBytes data) at UglyToad.PdfPig.Fonts.TrueType.Parser.TrueTypeFontParser.Parse(TrueTypeDataBytes data) at UglyToad.PdfPig.PdfFonts.Parser.Parts.CidFontFactory.ReadDescriptorFile(FontDescriptor descriptor) at UglyToad.PdfPig.PdfFonts.Parser.Parts.CidFontFactory.Generate(DictionaryToken dictionary) at UglyToad.PdfPig.PdfFonts.Parser.Handlers.Type0FontHandler.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.Parser.PageFactory.Create(Int32 number, DictionaryToken dictionary, PageTreeMembers pageTreeMembers, Boolean clipPaths) at UglyToad.PdfPig.Content.Pages.GetPage(Int32 pageNumber, Boolean clipPaths) at UglyToad.PdfPig.PdfDocument.GetPage(Int32 pageNumber) at UglyToad.PdfPig.PdfDocument.GetPages()+MoveNext()
A fix for this should go out in tonight's nightly build. Nightly builds are available at: https://www.nuget.org/packages/PdfPig.Nightly/
@EliotJones this particular exception is fixed, but now, using the nightly build we get another error when trying to generate a pdf.
UglyToad.PdfPig.Core.PdfDocumentFormatException Expected a IndirectReferenceToken for the XObject, got a DictionaryToken
@sharokh1 can you confirm your new issue is related to the old one? Maybe it's worth creating a new issue if this one is fixed.
Also, can you share a way to reproduce your new issue? What are you doing when you're creating the document.