PDFsharp & MigraDoc Foundation
https://forum.pdfsharp.net/

Error when opening pdf
https://forum.pdfsharp.net/viewtopic.php?f=2&t=1917
Page 1 of 1

Author:  sharpuser [ Wed Feb 22, 2012 10:13 am ]
Post subject:  Error when opening pdf

Hi

I have built an application using pdfsharp.dll (1.31.1789.0). The application combines several existing single pdf pages into a new pdf and then includes bookmarks to this new pdf. When the application runs on my and most other computer systems everything works fine (great tool!!). Unfortunately one user noticed problems when using the software: When opening the pdf files he produced on his system Adobe Reader says "There was an error processing a page. There was a problem reading this document (110)".
I performed a byte comparison of a sample file produced on my system resp. produced on the clients system and noticed slight differences:
Besides the "/CreationDate" and and ID almost at the end of the document there are (on the 8 page pdf file) 8 times the same following differences:

Working file: "/K -1"
Corrupt file: "/K _1"

The context within the pdf file where this can be found is the following:

...
/DecodeParms
<<
/K -1
/Columnms 2320
>>
/Length...
...

Is this difference the reason why Adobe can't read the pdf file?
How can the problem be solved?

Thanks a lot with kind regards!

Author:  Thomas Hoevel [ Wed Feb 22, 2012 12:30 pm ]
Post subject:  Re: Error when opening pdf

Hi!

Looks like a bug in PDFsharp.

I presume the user changed the Negative Number Symbol from "-" to "_". But this UI change should have no effect on the generated PDF files, but it does.

After "/K" a PdfInteger will be written, so I presume a change in PdfWriter will fix it:
Code:
public void Write(PdfInteger value)
{
  WriteSeparator(CharCat.Character);
  this.lastCat = CharCat.Character;
  WriteRaw(value.Value.ToString(CultureInfo.InvariantCulture));
}


But there are many other "value.ToString()" that should be changed to "value.ToString(CultureInfo.InvariantCulture)" to make PDF generation independent of user settings.

We'll fix this with PDFsharp 1.32 (coming out this week or next week or so).

Author:  sharpuser [ Wed Feb 22, 2012 1:22 pm ]
Post subject:  Re: Error when opening pdf

Thanks a lot for this quick reply and helpful hint!

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/