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

Bug: PdfReader.Open() (PDFsharp 1.5)
https://forum.pdfsharp.net/viewtopic.php?f=3&t=3057
Page 1 of 1

Author:  JahRkh [ Fri Feb 20, 2015 1:45 pm ]
Post subject:  Bug: PdfReader.Open() (PDFsharp 1.5)

If you try to open an PDF document with PDFsharp 1.32, you might get this exception:

Code:
Unhandled Exception: PdfSharp.Pdf.IO.PdfReaderException: Cannot handle iref streams. The current implementation of PDFsharp cannot handle this PDF feature introduced with Acrobat 6.

With PDFsharp 1.5 you will not get this exception, but there is a much bigger Problem! :shock:
If you try to open a document like this...

Code:
PdfDocument pd = PdfReader.Open(s);

... the program could get stuck in the function PdfReader.Open. :evil:

Please try to fix this bug.

Author:  () => true [ Sun Feb 22, 2015 6:10 pm ]
Post subject:  Re: Bug: PdfReader.Open() (PDFsharp 1.5)

Hi!
JahRkh wrote:
Please try to fix this bug.
Please submit the file that does not work to make sure the bug can be fixed.
There are many different "flavours" of PDF files.

Author:  steve_price [ Mon Mar 09, 2015 11:02 pm ]
Post subject:  Re: Bug: PdfReader.Open() (PDFsharp 1.5)

Hi, I have come across this problem as well in version 1.50.3638.

PdfSharp hangs when calling the method PdfReader.Open() with the below PDF:

PDF example that hangs in version 1.5

Interestingly, the PDF does open fine in version 1.32.3057, however there are other PDF files that cause the open method to hang in version 1.32.3057. An example PDF is below:

PDF example that hangs in version 1.32

I have tried opening both PDF files using a release build as this advise had resolved similar problems. Unfortunately this hasn't solved this issue.

I was unable to locate the source code for version 1.5 and therefore could not find any further information on what is causing the problem.

Any help with this issue would be great.

Thanks,
Steve

Author:  johnzered [ Thu May 21, 2015 10:18 am ]
Post subject:  Re: Bug: PdfReader.Open() (PDFsharp 1.5)

Any news about this? And also can we expect a new beta soon? The last beta is 5 months old, I'm sure you've nailed some nasty bugs since! 8)

Author:  hsimoes [ Fri Aug 21, 2015 4:28 pm ]
Post subject:  Re: Bug: PdfReader.Open() (PDFsharp 1.5)

It seems I have a similar problem. Did any of you found a solution?

Author:  TH-Soft [ Fri Aug 21, 2015 7:54 pm ]
Post subject:  Re: Bug: PdfReader.Open() (PDFsharp 1.5)

AFAIK all known bugs with respect to opening PDF files have been fixed with the latest internal builds of PDFsharp.
So wait patiently for the next beta. I don't know when it will come, but I hope it will come soon.

Author:  CodeCharm [ Wed Sep 23, 2015 12:41 am ]
Post subject:  Re: Bug: PdfReader.Open() (PDFsharp 1.5)

I'm getting this issue, too (hung inside PdfReader.Open()): NuGet package PDFsharp-MigraDoc-wpf 1.50.3638-beta

... but I'm getting it only in the Exception Handler where I'm using this workaround: http://forum.pdfsharp.net/viewtopic.php?f=2&t=693&p=5855#p5855 which I'm using because of a "Unexpected end of file" PdfReaderException in the Open() command:

PdfSharp-wpf.dll!PdfSharp.Pdf.IO.Parser.ParseObject(PdfSharp.Pdf.IO.Symbol stop) + 0x5c2 bytes
PdfSharp-wpf.dll!PdfSharp.Pdf.IO.Parser.ReadDictionary(PdfSharp.Pdf.PdfDictionary dict, bool includeReferences) + 0x61 bytes
PdfSharp-wpf.dll!PdfSharp.Pdf.IO.Parser.ReadObject(PdfSharp.Pdf.PdfObject pdfObject, PdfSharp.Pdf.PdfObjectID objectID, bool includeReferences, bool fromObjecStream) + 0x17a bytes
PdfSharp-wpf.dll!PdfSharp.Pdf.IO.Parser.ReadCompressedObject(int objectNumber, int offset) + 0x44 bytes
PdfSharp-wpf.dll!PdfSharp.Pdf.IO.Parser.ReadCompressedObject(PdfSharp.Pdf.PdfObjectID objectID, int index) + 0x13d bytes
PdfSharp-wpf.dll!PdfSharp.Pdf.IO.PdfReader.Open(System.IO.Stream stream, string password, PdfSharp.Pdf.IO.PdfDocumentOpenMode openmode, PdfSharp.Pdf.IO.PdfPasswordProvider passwordProvider) + 0x52f bytes
PdfSharp-wpf.dll!PdfSharp.Pdf.IO.PdfReader.Open(System.IO.Stream stream, PdfSharp.Pdf.IO.PdfDocumentOpenMode openmode) + 0x11 bytes

(Note that the NuGet beta doesn't include .pdb files, so I only have IL offsets.)

Any chance of treating this like an open-source project, where we can at least make our own forks to try to fix the specific problems we're having? I wouldn't necessarily expect you to take PRs, although of course, that might help you, too...

Or, maybe a super-detailed logging mode that could be enabled to help understand how we might modify the existing PDF file to make it successfully open?

Thanks,
->A

Author:  TH-Soft [ Wed Sep 23, 2015 5:41 am ]
Post subject:  Re: Bug: PdfReader.Open() (PDFsharp 1.5)

CodeCharm wrote:
I'm getting this issue, too (hung inside PdfReader.Open()): NuGet package PDFsharp-MigraDoc-wpf 1.50.3638-beta
That's the old beta.
If the problem persists with the current beta (1.50.3915-beta2) then it will be investigated if empira receives a sample file that allows to replicate the error.

Author:  CodeCharm [ Wed Sep 23, 2015 10:16 pm ]
Post subject:  Re: Bug: PdfReader.Open() (PDFsharp 1.5)

Thanks! That seems to have done the trick. The document loads without hanging.

BTW - I could not get the PdfSharp-MigraDoc-Gdi beta2 to properly render private fonts, even though I need to run this as a Web service. I had to resort to using PdfSharp-MigraDoc-Wpf beta2 for the private fonts to render. Also, XPrivateFontCollection.Add seems to work; I didn't have to implement IFontResolver. That seems to run against other instructions I've seen (http://stackoverflow.com/questions/27606877/pdfsharp-private-fonts-for-azure-1-50), so I don't know if it's working by accident (undocumented feature?) or if you meant for us to use it.

Author:  Thomas Hoevel [ Wed Sep 30, 2015 9:28 am ]
Post subject:  Re: Bug: PdfReader.Open() (PDFsharp 1.5)

Font management is still under construction.

With respect to PDFsharp 1.50 beta 2:
  • For GDI build use XPrivateFontCollection (IFontResolver does not work)
  • For WPF use XPrivateFontCollection if you use DocumentPreview, otherwise IFontResolver can also be used
  • For other platforms IFontResolver should be the method of choice

Maybe IFontResolver will work with a stable version of PDFsharp 1.50, maybe it won't.

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