|
PDFsharp - moved to http://forum.pdfsharp.net/ Please visit the new PDFsharp forum at http://forum.pdfsharp.net/
|
View previous topic :: View next topic |
Author |
Message |
simbolo
Joined: 14 Jan 2009 Posts: 7 Location: London, United Kingdom
|
Posted: Wed Jan 14, 2009 2:23 am Post subject: Corrupted (blank page) when using PDFs from SQL 2008 Reports |
|
|
Scenario:
A Microsoft SQL 2008 Database with Report Services (version 10) generates a PDF report. The report is 1 page long, some basic text, nothing fancy.
Using .Net code, the PDF is opened and saved, the result is a blank PDF (blank as viewed in Adobe PDF Reader 8, i.e., the content has been lost when the PDF goes through PDFSharp).
If I change the document title, default zoom etc, these settings are saved, but the PDF is still blank.
The same report, as generated per the previous version of SQL report services (version 9) runs through PDFSharp normally.
If I try to merge a PDF into the background of that report, like a PDF with a formatted header/footer using the code...
Code: | Dim gfx As XGraphics = XGraphics.FromPdfPage(FirstPage, XGraphicsPdfPageOptions.Prepend) |
...an exception is encountered when the above line of code is called. (This error doesn't occour on v9 PDFs, only since v10 was introduced)...
Code: |
PdfSharp.SharpZipLib.SharpZipBaseException: Header checksum illegal
at PdfSharp.SharpZipLib.Zip.Compression.Inflater.DecodeHeader() in PDFsharp\code\PdfSharp\PdfSharp.SharpZipLib\Zip\Compression\Inflater.cs:line 247
at PdfSharp.SharpZipLib.Zip.Compression.Inflater.Decode() in PDFsharp\code\PdfSharp\PdfSharp.SharpZipLib\Zip\Compression\Inflater.cs:line 427
at PdfSharp.SharpZipLib.Zip.Compression.Inflater.Inflate(Byte[] buf, Int32 offset, Int32 len) in PDFsharp\code\PdfSharp\PdfSharp.SharpZipLib\Zip\Compression\Inflater.cs:line 711
at PdfSharp.SharpZipLib.Zip.Compression.Streams.InflaterInputStream.Read(Byte[] b, Int32 off, Int32 len) in PDFsharp\code\PdfSharp\PdfSharp.SharpZipLib\Zip\Compression\Streams\InflaterInputStream.cs:line 409 |
Microsoft must have done something that upsets PDFSharp with their new rendering engine for PDFs, at this stage I am unsure which side the bug is in.
The PDF version of the report services pdf is 1.3 (Acrobat 4x).
Any suggestions?
Thanks. |
|
Back to top |
|
|
Thomas Hoevel
Joined: 16 Oct 2006 Posts: 387 Location: Cologne, Germany
|
Posted: Wed Jan 14, 2009 10:32 am Post subject: |
|
|
Hi!
We need a PDF file to replicate the problem. _________________ Regards
Thomas Hoevel
PDFsharp Team |
|
Back to top |
|
|
simbolo
Joined: 14 Jan 2009 Posts: 7 Location: London, United Kingdom
|
Posted: Wed Jan 14, 2009 2:17 pm Post subject: |
|
|
Yes that would be handy, here is the PDF, it's directly out of Report Services 10.
http://cid-6e64738c64f8f959.skydrive.live.com/self.aspx/Public/101O.pdf
To get PDFSharp to make it into a blank PDF...
Code: | Imports PdfSharp
Imports PdfSharp.Pdf
Imports PdfSharp.Pdf.IO
Imports PdfSharp.Drawing
Dim cStatement As PdfDocument = PdfReader.Open(FilePathToPDF)
cStatement.Info.Subject = "An example change."
cStatement.Save(FilePathToPDF) |
The subject text is preserved in the blank pdf.
To create the checksum exception...
Code: | Dim lMerge As XPdfForm = XPdfForm.FromFile(OverlayPDFFilePath)
Dim FirstPage As PdfPage = cStatement.Pages(0)
Dim gfx As XGraphics = XGraphics.FromPdfPage(FirstPage, XGraphicsPdfPageOptions.Prepend)
Dim width As Double = FirstPage.Width
Dim height As Double = FirstPage.Height
Dim box As XRect = New XRect(0, 0, width, height)
gfx.DrawImage(lMerge, box)
cStatement.Save(FilePath) |
The purpose of the above code is to merge a PDF containing a letterhead onto the target PDF document. The letterhead PDF has been working fine with PDFSharp. The letterhead is only merged onto page 1 of the document.
I hope this is usefull. Thanks. |
|
Back to top |
|
|
simbolo
Joined: 14 Jan 2009 Posts: 7 Location: London, United Kingdom
|
Posted: Mon Jan 19, 2009 6:44 pm Post subject: Debug Output |
|
|
Have been playing around with the Report Services, the only configuration available is to enable compression (as disabled by default), as the error seems related to a ZIP checksum.
Would be terriffic to get this to work, as SQL Report Services 10 can render HTML as PDF, and is free.
I have observed the following debug output messages:
Quote: | UserOrOwnerPasswordRequired: 'At least a user or an owner password is required to encrypt the document.'
UnexpectedToken: 'Token '{0}' was not expected.'
UnknownEncryption: 'The PDF document is protected with an encryption not supported by PDFsharp.' |
These messages only appear on the report services 10 PDF, and not the older v9s. There appears to be some unknown symbol (which isn't showing up in the debug message {0}), and curiously, the PDF isn't encrypted or protected.
Still investigating. |
|
Back to top |
|
|
simbolo
Joined: 14 Jan 2009 Posts: 7 Location: London, United Kingdom
|
Posted: Mon Jan 19, 2009 8:54 pm Post subject: Cannot trace. |
|
|
I couldn't trace where the encyption checking was done, but the exceptions seems to originate from Parser.cs
Code: | Symbol ReadSymbol(Symbol symbol)
{
Symbol current = this.lexer.ScanNextToken();
if (symbol != current)
throw new PdfReaderException(PSSR.UnexpectedToken(this.lexer.Token));
return current;
} |
the ScanNextToken seems to encounter an unknown Symbol (not implemented"), the exception occours despite the code returning a Symbol.None.
Unsure how to examine the unrecognised symbol, if I break at the end of ScanNextToken() and look at the value for this.symbol in the VS Locals window, the value is set to "PdfSharp.Pdf.IO.Symbol.BeginStream", here are the other values. Setting to return Symbol.BeginStream instead of Symbol.None has no effect.
Quote: | - this {PdfSharp.Pdf.IO.Lexer} PdfSharp.Pdf.IO.Lexer
currChar 136 '?' char
idxChar 3498 int
nextChar 188 '¼' char
+ pdf {System.IO.FileStream} System.IO.Stream {System.IO.FileStream}
PdfLength 8825 int
pdfLength 8825 int
Position 3498 int
symbol BeginStream PdfSharp.Pdf.IO.Symbol
Symbol BeginStream PdfSharp.Pdf.IO.Symbol
+ token {} System.Text.StringBuilder
Token "" string
+ TokenToBoolean 'this.TokenToBoolean' threw an exception of type 'System.IndexOutOfRangeException' bool {System.IndexOutOfRangeException}
+ TokenToInteger 'this.TokenToInteger' threw an exception of type 'System.FormatException' int {System.FormatException}
+ TokenToReal 'this.TokenToReal' threw an exception of type 'System.FormatException' double {System.FormatException}
+ TokenToUInteger 'this.TokenToUInteger' threw an exception of type 'System.FormatException' uint {System.FormatException}
ch 136 '?' char |
Removing the debug.asserts just results in the code completing without exception, but just giving me a blank PDF (which is larger in size than the original PDF put in).
Is a BeginStream Symbol abnormal? |
|
Back to top |
|
|
simbolo
Joined: 14 Jan 2009 Posts: 7 Location: London, United Kingdom
|
Posted: Sat Feb 07, 2009 3:38 pm Post subject: Status update. |
|
|
I've still not managed to find a solution to this.
Did anyone receive the PDF I sent over?
I notice a similiar Unknown Symbol problem was fixed in the support thread of this forum with just 2 lines of code, so I expect there must be a similiar solution for me? |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|