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

Exception when trying to combine pdfs
https://forum.pdfsharp.net/viewtopic.php?f=3&t=3229
Page 1 of 1

Author:  johnzered [ Thu Nov 26, 2015 1:15 pm ]
Post subject:  Exception when trying to combine pdfs

Hi,

I'm trying to combine two pdf's using your sample code, http://www.pdfsharp.net/wiki/CombineDoc ... ample.ashx.
But PdfSharp throws the following exception: PdfSharp.SharpZipLib.SharpZipBaseException: Deflated stream ends early on line: gfx = XGraphics.FromPdfPage(page1);

Testapplication including a pdf as well as a workaround in the comments in static void Main(string[] args)
can be found here: Example file removed.

Is this something that can be fixed in your end or is there something wrong with my pdf?

Reason for edit: Example file removed.

Author:  Thomas Hoevel [ Thu Nov 26, 2015 1:49 pm ]
Post subject:  Re: Exception when trying to combine pdfs

Hi!
johnzered wrote:
Is this something that can be fixed in your end or is there something wrong with my pdf?
Thanks for the feedback. At first glance it looks like a problem with our library (with an external library used by our library actually), but I cannot address this issue this week.

Author:  johnzered [ Fri Dec 04, 2015 8:34 am ]
Post subject:  Re: Exception when trying to combine pdfs

Have you had time to investigate this issue any further?

Author:  johnzered [ Thu Dec 10, 2015 8:08 am ]
Post subject:  Re: Exception when trying to combine pdfs

I'm sorry to keep nagging about this but it's crucial for our own development to know if you think there's something you can do about this.
We are not in an immediate rush so if you're working on this or thinks there's a problem you will be able to solve it's okay, just want to here your comments.

Author:  Thomas Hoevel [ Thu Dec 10, 2015 9:25 am ]
Post subject:  Re: Exception when trying to combine pdfs

I've updated PDFsharp to use the latest version of the SharpZipLib and the problem persists.

In 10+ years I think this is the first valid PDF file that cannot be read by PDFsharp because of what seems to be a bug in SharpZipLib.
Looks like a problem that occurs with one in a million files.

I think I cannot solve it.

You can try to solve it, now that the source code for PDFsharp is available.

I don't know if the SharpZipLib Team is willing to help with this problem. I'm afraid it'll take hours to create a small example that replicates the problem and allows them to investigate and fix the issue.
I'm afraid we won't address this problem in the near future. We have bigger problems to deal with.

I don't understand why this file is crucial for you.

Author:  johnzered [ Thu Dec 10, 2015 2:09 pm ]
Post subject:  Re: Exception when trying to combine pdfs

The PDF provided in the tesproject was just used as an example and has absolutely no meaning to me what so ever. But I cannot provide you with a real world business document and actually that doesn't matter as the error occurs with any of our documents.
As mentioned in the comments of the example project (in Main method) we convert RTF files to PDF using a third party library and every PDF created with that library fails to be combined using your library.

Also in the comments I explained about a fix for this issue:

Changing the code in a file called FlateDecode.cs in the current codeplex source code after the #else for #if NET_ZIP into
Code:
byte header;   // 0x30 0x59
header = (byte)msInput.ReadByte();
//Debug.Assert(header == 48);
header = (byte)msInput.ReadByte();
//Debug.Assert(header == 89);

InflaterInputStream iis = new InflaterInputStream(msInput, new Inflater(true));
from just
Code:
InflaterInputStream iis = new InflaterInputStream(msInput, new Inflater(false));

The problem is we do not know the side effects of such a change.

Thank you for your help.

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