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

PDFsharp.1.50.4619-beta4c PDF document read issue
https://forum.pdfsharp.net/viewtopic.php?f=2&t=3686
Page 1 of 1

Author:  FACAMK [ Mon Nov 06, 2017 10:52 am ]
Post subject:  PDFsharp.1.50.4619-beta4c PDF document read issue

Hi There,

I just upgraded from the stable 1.32.3057 to the beta 1.50.4619-beta4c and some PDF documents cannot be read (I cannot provide those documents as they are confidential), but I can provide the error:
at PdfSharp.Pdf.Security.PdfStandardSecurityHandler.PrepareRC4Key(Byte[] key, Int32 offset, Int32 length)
at PdfSharp.Pdf.Security.PdfStandardSecurityHandler.EncryptDictionary(PdfDictionary dict)
at PdfSharp.Pdf.Security.PdfStandardSecurityHandler.EncryptObject(PdfObject value)
at PdfSharp.Pdf.Security.PdfStandardSecurityHandler.EncryptDocument()
at PdfSharp.Pdf.IO.PdfReader.Open(Stream stream, String password, PdfDocumentOpenMode openmode, PdfPasswordProvider passwordProvider)
at PdfSharp.Pdf.IO.PdfReader.Open(Stream stream, PdfDocumentOpenMode openmode)
at Program.GetPDF() in MY_PROJECT
at Program.Main(String[] args) in MY_APP

I upgraded to 1.50.4619-beta4c because it enabled me to do something i cant quite remember why I couldn't do it with the non beta version (was 2-3 months ago)
I was able to load the files with v1.32.3057

Author:  Thomas Hoevel [ Mon Nov 06, 2017 12:29 pm ]
Post subject:  Re: PDFsharp.1.50.4619-beta4c PDF document read issue

Note for self: Similar issue with sample code on GitHub:
https://github.com/empira/PDFsharp/issues/31

Author:  FACAMK [ Mon Nov 06, 2017 1:52 pm ]
Post subject:  Re: PDFsharp.1.50.4619-beta4c PDF document read issue

Now I have it happening on another module of our code where we split a pdf into multiple pdf files (please see the attached file for more details).

Attachments:
ProcessFileError.png
ProcessFileError.png [ 23.18 KiB | Viewed 8875 times ]

Author:  Thomas Hoevel [ Mon Nov 06, 2017 4:37 pm ]
Post subject:  Re: PDFsharp.1.50.4619-beta4c PDF document read issue

It seems this problem occurs with beta 4c, but not with beta 4.
When using NuGet packages, consider going back to beta 4 until a new version comes out.

Author:  FACAMK [ Tue Nov 07, 2017 7:14 am ]
Post subject:  Re: PDFsharp.1.50.4619-beta4c PDF document read issue

Ok, I'll give it a try and see if that fixes our issue.

Thank you.

Author:  FACAMK [ Tue Nov 07, 2017 1:13 pm ]
Post subject:  Re: PDFsharp.1.50.4619-beta4c PDF document read issue

Does not work with beta4, its the same issue again.

Author:  Thomas Hoevel [ Tue Nov 07, 2017 2:02 pm ]
Post subject:  Re: PDFsharp.1.50.4619-beta4c PDF document read issue

FACAMK wrote:
Does not work with beta4, its the same issue again.
I guess there are two issues:
  • Crash at PdfReader.Open
  • Crash at PageCount
The former may not occur with beta 4 (but we don't have a PDF file to test it), the latter is a different matter.

Author:  FACAMK [ Tue Nov 07, 2017 2:29 pm ]
Post subject:  Re: PDFsharp.1.50.4619-beta4c PDF document read issue

I downgraded to 1.32 and this is the error I get when reading the document:
at PdfSharp.Pdf.PdfPages.GetKids(PdfReference iref, InheritedValues values, PdfDictionary parent)
at PdfSharp.Pdf.PdfPages.FlattenPageTree()
at PdfSharp.Pdf.Advanced.PdfCatalog.get_Pages()
at PdfSharp.Pdf.PdfDocument.get_Pages()
at PdfSharp.Pdf.IO.PdfReader.Open(Stream stream, String password, PdfDocumentOpenMode openmode, PdfPasswordProvider passwordProvider)
at PdfSharp.Pdf.IO.PdfReader.Open(Stream stream, PdfDocumentOpenMode openmode)

The document has the properties listed int the attached image.
Attachment:
Screenshot_7.png
Screenshot_7.png [ 16.05 KiB | Viewed 8864 times ]

Attachment:
DocProperties.png
DocProperties.png [ 17.93 KiB | Viewed 8864 times ]

Author:  MarcoBee [ Wed Nov 29, 2017 4:09 pm ]
Post subject:  Re: PDFsharp.1.50.4619-beta4c PDF document read issue

I also have the same issue on PageCount.
Actually I use PDFSharp in VB.Net only for splitting pages from incoming PDFs. We get PDF files via mail by several senders, and I saw that this problem arises only with the PDFs from a specific sender.

I tried the beta4c release, as well as beta4 and last stable release 1.32.3057 + some previous release: in every case, I have the same issue on the same PDF type (I guess that sender creates the same type of PDF).
I can of course provide specifici PDF samples.

Is there (or will be) any solution to this issue?

Thanks

Author:  Thomas Hoevel [ Wed Nov 29, 2017 4:40 pm ]
Post subject:  Re: PDFsharp.1.50.4619-beta4c PDF document read issue

MarcoBee wrote:
Is there (or will be) any solution to this issue?
If the PDF file complies with the PDF specification then we will try to support it, i.e. make PDFsharp open it correctly.
If the PDF file is corrupt then we may not be able to alter PDFsharp to read it.

Some initialization is done when calling PageCount for the first time. Various forms of corrupted PDF files can lead to problems at that point. Maybe that one sender uses a tool that produces incorrect PDF files.

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