PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Thu Mar 28, 2024 4:31 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: Mon Dec 10, 2007 12:05 pm 
Offline

Joined: Mon Dec 10, 2007 11:53 am
Posts: 1
Hello!

In one of my projects I have to merge PDF files (produced by SAP) into one big PDF. I tried your library and found a bug in either the library or (also possible) the PDFs I have to merge.

In the function ReadTrailer() you are reading the last 30 bytes and then you search for the startxref symbol. My PDFs I got for testing have a lot of \0 bytes at the end (more than 30! ) which will make it impossible for your ReadTrailer-function to find the requested symbol. I corrected the function to be able to read my PDFs from SAP in the following way:

internal PdfTrailer ReadTrailer()
{
//Symbol symbol;
//string token;
//int xrefOffset = 0;
int length = lexer.PdfLength;

// YOUR ORIGINAL CODE --> COMMENTED OUT
//string trail = this.lexer.ReadRawString(length - 31, 30); //lexer.Pdf.Substring(length - 30);
//int idx = trail.IndexOf("startxref");

// SCANNING THE WHOLE DOCUMENT FOR THE LAST startxref -> will also work if bytes are added at the end
string trail = this.lexer.ReadRawString(0, length);
int idx = trail.LastIndexOf("startxref");

//this.lexer.Position = length - 31 + idx;
this.lexer.Position = idx;

ReadSymbol(Symbol.StartXRef);
this.lexer.Position = ReadInteger();
...

I just wanted to give a feedback to this problem, maybe it is useful for you and you can consider it for future versions.

Bye,

Wilfried Mausz


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 56 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