PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Sat Sep 26, 2020 6:02 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 

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

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;

//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;

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.


Wilfried Mausz

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 7 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