UglyToad / PdfPig

Read and extract text and other content from PDFs in C# (port of PDFBox)
https://github.com/UglyToad/PdfPig/wiki
Apache License 2.0
1.73k stars 241 forks source link

0.1.8 crashes when reading a file #724

Closed marcRobertHabib closed 1 year ago

marcRobertHabib commented 1 year ago

Hi, Thanks for your work

File https://www.medikamente-per-klick.de/images/ecommerce/11/19/11194059_2017-11_de_s.pdf crashes with version 0.1.8 only on GetPages with error:

System.ArgumentOutOfRangeException: Non-negative number required. (Parameter 'index') at System.Collections.Generic.List1.GetRange(Int32 index, Int32 count) at UglyToad.PdfPig.Functions.Type4.StackOperators.Copy.Execute(ExecutionContext context) at UglyToad.PdfPig.Functions.Type4.InstructionSequence.Execute(ExecutionContext context) at UglyToad.PdfPig.Functions.Type4.InstructionSequence.Execute(ExecutionContext context) at UglyToad.PdfPig.Functions.PdfFunctionType4.Eval(Double[] input) at UglyToad.PdfPig.Graphics.Colors.DeviceNColorSpaceDetails.GetColor(Double[] values) at UglyToad.PdfPig.Graphics.Colors.DeviceNColorSpaceDetails.GetInitializeColor() at UglyToad.PdfPig.Graphics.ColorSpaceContext.SetNonStrokingColorspace(NameToken colorspace, DictionaryToken dictionary) at UglyToad.PdfPig.Graphics.Operations.SetNonStrokeColorSpace.Run(IOperationContext operationContext) at UglyToad.PdfPig.Graphics.ContentStreamProcessor.ProcessOperations(IReadOnlyList1 operations) at UglyToad.PdfPig.Graphics.ContentStreamProcessor.Process(Int32 pageNumberCurrent, IReadOnlyList1 operations) at UglyToad.PdfPig.Parser.PageFactory.GetContent(Int32 pageNumber, IReadOnlyList1 contentBytes, CropBox cropBox, UserSpaceUnit userSpaceUnit, PageRotationDegrees rotation, MediaBox mediaBox, InternalParsingOptions parsingOptions) at UglyToad.PdfPig.Parser.PageFactory.Create(Int32 number, DictionaryToken dictionary, PageTreeMembers pageTreeMembers, NamedDestinations namedDestinations, InternalParsingOptions parsingOptions) at UglyToad.PdfPig.Content.Pages.GetPage(Int32 pageNumber, NamedDestinations namedDestinations, InternalParsingOptions parsingOptions) at UglyToad.PdfPig.PdfDocument.GetPage(Int32 pageNumber) at UglyToad.PdfPig.PdfDocument.GetPages()+MoveNext()

BobLd commented 1 year ago

@marcRobertHabib thanks for raising the issue and providing a sample document. I've raised a PR to fix the bug

marcRobertHabib commented 9 months ago

Thanks

How can I get a fixed version?

BobLd commented 9 months ago

@marcRobertHabib you can use the latest nightly release of the NuGet package