PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Sun Jul 14, 2024 6:21 pm

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
PostPosted: Wed Feb 04, 2009 5:04 am 
Offline

Joined: Wed Feb 04, 2009 4:44 am
Posts: 1
Hi,

When I open PDF file with Modify mode am getting error message. i.e Unexpected token in PDF file. The PDF file may be currupt. If it is not, please send us the file for serivce.

Code:
Code:
PdfSharp.Pdf.IO.PdfReader.Open(filePath, PdfSharp.Pdf.IO.PdfDocumentOpenMode.Modify);


Please give the solutions.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Wed Feb 04, 2009 10:39 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3101
Location: Cologne, Germany
Hi!

We need the PDF file to investigate the issue.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Wed Feb 04, 2009 4:16 pm 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3101
Location: Cologne, Germany
Hi!

The file is not corrupted, but contains an unusual name/value pair.

Here's a fix for that: in PdfRectangle.cs (2 new lines):
Code:
internal PdfRectangle(PdfItem item)
{
  if (item == null)
    return;

  // 2 new lines below:
  if (item is PdfNull)
    return;
  // 2 new lines above

  if (item is PdfReference)
    item = ((PdfReference)item).Value;

  PdfArray array = item as PdfArray;
  if (array == null)
    throw new InvalidOperationException(PSSR.UnexpectedTokenInPdfFile);

  this.x1 = array.Elements.GetReal(0);
  this.y1 = array.Elements.GetReal(1);
  this.x2 = array.Elements.GetReal(2);
  this.y2 = array.Elements.GetReal(3);
}


This is not the solution for all "unexpected token" errors, but at least for one.

_________________
Regards
Thomas Hoevel
PDFsharp Team


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: No registered users and 49 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