PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Tue Apr 23, 2024 8:55 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Generated PDF Errors
PostPosted: Fri Aug 17, 2007 6:26 pm 
Offline

Joined: Fri Mar 23, 2007 11:37 pm
Posts: 16
Location: Berlin
Hello,
I used migradoc 1.2.1930.0 and pdfsharp 0.9.653.0 to create a pdf file. However I cannot import that pdf file using pdflib as it says it contains errors.

Furthermore when I open the pdf file using Adobe Acrobat, the file is being repaired. After that I installed another analyzing tool that spit out the following errors:

2x The end-of-file marker was not found.
1x The 'startxref' keyword or the xref position was not found.

If somebody got a clue or might be able to help me, I can send the "corrupted" pdf for further examination. Just cannot post it here as it contains internal information.

Regards,
André


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sat Aug 18, 2007 3:26 pm 
Offline

Joined: Fri Mar 23, 2007 11:37 pm
Posts: 16
Location: Berlin
Something to add:

After trying to open the generated PDF using PdfReader.Open I get the following error:

Code:
PdfSharp.Pdf.IO.PdfReaderException: Token '' was not expected.
   bei PdfSharp.Pdf.IO.Parser.ReadSymbol(Symbol symbol) in D:\Projects2\delivergo\PDFSharp 1.0.898\PDFsharp\PdfSharp\PdfSharp.Pdf.IO\Parser.cs:Zeile 541.
   bei PdfSharp.Pdf.IO.Parser.ReadTrailer() in D:\Projects2\delivergo\PDFSharp 1.0.898\PDFsharp\PdfSharp\PdfSharp.Pdf.IO\Parser.cs:Zeile 711.
   bei PdfSharp.Pdf.IO.PdfReader.Open(Stream stream, String password, PdfDocumentOpenMode openmode, PdfPasswordProvider passwordProvider) in D:\Projects2\delivergo\PDFSharp 1.0.898\PDFsharp\PdfSharp\PdfSharp.Pdf.IO\PdfReader.cs:Zeile 275.
   bei PdfSharp.Pdf.IO.PdfReader.Open(Stream stream, String password, PdfDocumentOpenMode openmode) in D:\Projects2\delivergo\PDFSharp 1.0.898\PDFsharp\PdfSharp\PdfSharp.Pdf.IO\PdfReader.cs:Zeile 247.
   bei PdfSharp.Pdf.IO.PdfReader.Open(Stream stream, PdfDocumentOpenMode openmode) in D:\Projects2\delivergo\PDFSharp 1.0.898\PDFsharp\PdfSharp\PdfSharp.Pdf.IO\PdfReader.cs:Zeile 232.


Regards,
André


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sun Aug 19, 2007 4:44 pm 
Offline

Joined: Fri Mar 23, 2007 11:37 pm
Posts: 16
Location: Berlin
Hi there,
I produced the fault on my own, but I want others to not run into the same problem. I used a MemoryStream to save the generated document in. Later on I need a byteArray out of that(for a webservice).

To get the byteArray I used the
Code:
memoryStream.GetBuffer()
method of the MemoryStream which unfortunately gets the whole buffer INCLUDING zero padding at the end of the stream. So that is what produced the "corrupted" pdf files.

MemoryStreams grow dynamically and when the size is being increased the yet unused space is filled with zeros. So better use
Code:
memoryStream.ToArray
for small amount of data or something like
Code:
fileStream.Write(memoryStream.GetBuffer(), 0, memoryStream.Position);
when using big files.

Regards,
André


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 196 guests


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 post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group