View previous topic :: View next topic |
Author |
Message |
cg_sireesh
Joined: 04 Feb 2009 Posts: 1
|
Posted: Wed Feb 04, 2009 5:04 am Post subject: Unexpected token in PDF file |
|
|
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 |
|
 |
Thomas Hoevel

Joined: 16 Oct 2006 Posts: 387 Location: Cologne, Germany
|
Posted: Wed Feb 04, 2009 10:39 am Post subject: |
|
|
Hi!
We need the PDF file to investigate the issue. _________________ Regards
Thomas Hoevel
PDFsharp Team |
|
Back to top |
|
 |
Thomas Hoevel

Joined: 16 Oct 2006 Posts: 387 Location: Cologne, Germany
|
Posted: Wed Feb 04, 2009 4:16 pm Post subject: |
|
|
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 |
|
 |
|