empira / PDFsharp-1.5

A .NET library for processing PDF
MIT License
1.28k stars 588 forks source link

Issue reading valid PDF file, GetReal: Object is not a number. #101

Open decryphe opened 5 years ago

decryphe commented 5 years ago

Hello Everyone

There is a crash in PdfSharp when appending some of my PDF files to a longer master file. Attached is a minimum working sample that triggers this bug. Stacktrace is as follows: Unhandled Exception: System.InvalidCastException: GetReal: Object is not a number. at PdfSharp.Pdf.PdfArray.ArrayElements.GetReal(Int32 index) at PdfSharp.Pdf.PdfDictionary.DictionaryElements.GetRectangle(String key, Boolean create) at PdfSharp.Pdf.PdfPage.get_MediaBox() at PdfSharp.Pdf.PdfPage.WriteObject(PdfWriter writer) at PdfSharp.Pdf.PdfDocument.DoSave(PdfWriter writer) at PdfSharp.Pdf.PdfDocument.Save(Stream stream, Boolean closeStream) at PdfSharp.Pdf.PdfDocument.Save(String path) at IssueSubmission.Program.Main() in C:\Users\user\Downloads\PDFsharp-IssueSubmission\IssueSubmission\Program.cs:line 38

File is generated with WeasyPrint and sanitized with PDF-Xchange editor. Original WeasyPrint file doesn't work as well as sanitized version from PDF-Xchange.

PDFsharp-IssueSubmission.zip

ThomasHoevel commented 1 year ago

Thanks for the feedback. Sorry it took so long. Error will be fixed with PDFsharp 6.0.0-preview-3 coming this month or next month.