PDFsharp - moved to http://forum.pdfsharp.net/ Forum Index PDFsharp - moved to http://forum.pdfsharp.net/
Please visit the new PDFsharp forum at http://forum.pdfsharp.net/
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Unexpected token in PDF file

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    PDFsharp - moved to http://forum.pdfsharp.net/ Forum Index -> Support - moved to http://forum.pdfsharp.net/
View previous topic :: View next topic  
Author Message
cg_sireesh



Joined: 04 Feb 2009
Posts: 1

PostPosted: Wed Feb 04, 2009 5:04 am    Post subject: Unexpected token in PDF file Reply with quote

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.
Back to top
View user's profile Send private message
Thomas Hoevel



Joined: 16 Oct 2006
Posts: 387
Location: Cologne, Germany

PostPosted: Wed Feb 04, 2009 10:39 am    Post subject: Reply with quote

Hi!

We need the PDF file to investigate the issue.
_________________
Regards
Thomas Hoevel
PDFsharp Team
Back to top
View user's profile Send private message Visit poster's website
Thomas Hoevel



Joined: 16 Oct 2006
Posts: 387
Location: Cologne, Germany

PostPosted: Wed Feb 04, 2009 4:16 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    PDFsharp - moved to http://forum.pdfsharp.net/ Forum Index -> Support - moved to http://forum.pdfsharp.net/ All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © phpBB Group. Hosted by phpBB.BizHat.com


Start Your Own YouTube Clone

Free Web Hosting | Free Forum Hosting | FlashWebHost.com | Image Hosting | Photo Gallery | FreeMarriage.com

Powered by PhpBBweb.com, setup your forum now!
For Support, visit Forums.BizHat.com