Closed tyler-boyd closed 1 year ago
If anyone is struggling with this and needs a workaround, I've published https://www.nuget.org/packages/PdfSharpTr/0.0.3 which is the latest stable release but with the PdfSharp.dll replaced with the version from building my PR.
Version 0.0 is still not supported. We fixed a bug that caused PDFsharp to write files with version 0.0. Please try preview 1 or later of PDFsharp 6.0.0.
Hi, first, thanks for all the work on PDFSharp! It's an awesome library and has been very helpful.
Reporting an Issue Here
I am consuming a document generated by someone else using PDFSharp 1.32. I am parsing it with the latest 1.50 version of PDFSharp. I can see that the version header is
%PDF-0.0.%
in the PDF, and all viewers I tested were able to open it, but PDFSharp was not due to it interpreting version 0.0 the same as an error case.Expected Behavior
Actual Behavior
InvalidPdf
error is thrown because the version was parsed as 0PdfReader.GetPdfFileVersion
, the returned value is 0, and the caller can't differentiate between version 0.0 and the error case (as this function returns 0 for any exception as well)Steps to Reproduce the Behavior
I can include an IssueSubmissionTemplate if necessary, but I figure this is a trivial issue. test.pdf
Solutioning
Ideally, PDFSharp shouldn't generate version 0.0 documents (related issue: https://github.com/empira/PDFsharp/issues/127). But since other PDF readers can handle it, I think the real fix would be to change the
GetPdfFileVersion
function to differentiate between version 0.0 and the error case. It may be as simple as changing the error case return value to-1
.