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

Incorrect value of PDF boolean object #53

Open
uzair08inator opened this issue Apr 17, 2018 · 6 comments
Open

Incorrect value of PDF boolean object #53

uzair08inator opened this issue Apr 17, 2018 · 6 comments

Comments

@uzair08inator
Copy link

I am writing a PDF file using PDFSharp. For some reason the value of a boolean object is written as 'False' instead of 'false' (notice the upper case 'F')

As a result while i am reading the file again i am getting following error in PDFSharp
"Unexpected token 'False' in PDF stream. The file may be corrupted. If you think this is a bug in PDFsharp, please send us your PDF file."

PDFSharp version: Assembly PdfSharp.dll, v1.50.4740.0

@TH-Soft
Copy link
Contributor

TH-Soft commented Apr 17, 2018

If you think there is a bug in PDFsharp then please use the IssueSubmissionTemplate to make the issue replicable.
http://www.pdfsharp.net/wiki/IssueSubmissions.ashx

Thanks.

@uzair08inator
Copy link
Author

To reproduce the error all the code required is following:

PdfDocument pdfDoc = PdfSharp.Pdf.IO.PdfReader.Open("file.pdf");
pdfDoc.Save(fileCopy.pdf");
pdfDoc = PdfSharp.Pdf.IO.PdfReader.Open("fileCopy.pdf");

In line 3 i am getting error: "Unexpected token 'False' in PDF stream. The file may be corrupted. If you think this is a bug in PDFsharp, please send us your PDF file."

All you need is the PDF sample that i am using. But unfortunately i cant share the PDF sample with you because it is a client file.

Is there any other way?

@TH-Soft TH-Soft added the not repro As a matter of principle we only investigate non-trivial issues that are replicable (VS solution) label Apr 20, 2018
@TH-Soft
Copy link
Contributor

TH-Soft commented Apr 20, 2018

Without "file.pdf" I cannot replicate the issue.
There are many PDF files that do not show this problem.

Please let us know when you find a non-confidential PDF file that allows to replicate the issue.

@REDECODE
Copy link

Same for me (but with "True" instead of "False").. even if I not modify nothing in the PDF just open and save the result PDF load in Google Chrome but not in Acrobat Pdf Reader (error).

Like @uzair08inator say if i open the result pdf with notepad++ i can see a row with a "True" and if i modify in "true" and save than I can open the pdf with Acrobat Reader correctly.

I cannot share the PDF but I can show you some rows with the "True" (the 4th line) instead of the correct "true":

endobj
62 0 obj
True
endobj
63 0 obj
<<
/AP
<<
/N 297 0 R

/F 4
/MK
<<

/P 25 0 R
/Parent 9 0 R

@REDECODE
Copy link

Ok, I solved modify PdfWriter.cs on line 105 making it similar to line 115.

Replace:

WriteRaw(value ? bool.TrueString : bool.FalseString);

with:

WriteRaw(value ? "true" : "false");

@jwarner00
Copy link

This reproduces with the attached pdf file, also available here:
https://www.irs.gov/pub/irs-prior/f1095c--2021.pdf
f1095c--2021.pdf

A full fix would include changes to Lexer.cs to include cases for both casings of true and false (line 360), as well as modifications to the four places the code references bool.TrueString / bool.FalseString.

@ThomasHoevel ThomasHoevel added review pending and removed not repro As a matter of principle we only investigate non-trivial issues that are replicable (VS solution) labels Jun 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants