PDFsharp & MigraDoc Foundation
https://forum.pdfsharp.net/

Unknown Escape Character When Opening File
https://forum.pdfsharp.net/viewtopic.php?f=2&t=1571
Page 1 of 1

Author:  sswope [ Tue Mar 08, 2011 1:00 am ]
Post subject:  Unknown Escape Character When Opening File

We have an application that, among other things, merges several PDFs together with PDFSharp. It works correctly except for a few files created by AutoCAD. When we try to open one in debug mode, we get a "Not implemented: unknown escape character" in Lexer.ScanLiteralString().

Here is our current code to open the files. A sample PDF that produces the error is attached.

Code:
' Open the document to import pages from it.
Dim InputDocument As PdfDocument = PdfReader.Open("Sample.pdf", PdfDocumentOpenMode.Import)

' Iterate pages
Dim PageCount As Integer = InputDocument.PageCount
For PageIndex As Integer = 0 To PageCount - 1
   ' Get the page from the external document...
   Dim page As PdfPage = InputDocument.Pages(PageIndex)
   ' ...and add it to the output document.
   AddedPage = OutputDocument.AddPage(page)
Next

If we run in release mode, we don't get any errors on the Open but instead get a null reference error on the Pages collection.

This has become an escalated issue with one of our clients and we would like an estimate of the time and cost to have you fix this issue. Please reply to this account's email.

Thank you,
Sean Swope
Chief Software Architect
Synergis Software

Attachments:
Sample.zip [1.37 KiB]
Downloaded 700 times

Author:  Stefan Lange [ Tue Mar 08, 2011 10:28 pm ]
Post subject:  Re: Unknown Escape Character When Opening File

The PDF file contains two elements that are not valid referring to the PDF Reference of Adobe. One element is (\ ). A backslash followed by a blank is not a valid escape sequence. The other element is the number 264584027963392 which is neither a 32 bit integer (too large) nor a PDF real value (missing the decimal point).

I fixed the issues by treating “backslash blank” simply as blank and too large numbers as real values.

With this fixes PDFsharp handles this PDF file. I will send you a copy of Lexer.cs by email.

Regards
Stefan Lange

Author:  sswope [ Wed Mar 09, 2011 3:54 pm ]
Post subject:  Re: Unknown Escape Character When Opening File

I received the file and it works perfectly. Thank you for the quick response and fix. That is amazing customer support. Please keep up the great work on an exceptional product.

Thank you,
Sean Swope
Chief Software Architect
Synergis Software

Author:  alecb [ Mon Oct 07, 2013 11:33 pm ]
Post subject:  Re: Unknown Escape Character When Opening File

Hi Stefan,

We are also receiving the same error when working with pdfs generated by the AutoCAD product.
It would be greatly appreciated if you're able to provide the updated Lexer.cs file?

Thanks,
Alec.

Author:  craigii [ Mon Jun 06, 2016 2:59 pm ]
Post subject:  Re: Unknown Escape Character When Opening File

I'm using version 1.32 and am running into the same issue with pdf documents created from AutoCAD. Is this fix available anywhere?

Thanks,

Author:  Thomas Hoevel [ Mon Jun 06, 2016 3:13 pm ]
Post subject:  Re: Unknown Escape Character When Opening File

Hi!

Have you tried version 1.50 beta 3?

As far as I can tell from the source, both fixes mentioned here have been included with PDFsharp 1.50.
You can use Lexer.cs to patch your PDFsharp 1.32 if migration to 1.50 is not an option.

Author:  craigii [ Mon Jun 06, 2016 3:14 pm ]
Post subject:  Re: Unknown Escape Character When Opening File

I have not.

Author:  craigii [ Mon Jun 06, 2016 3:19 pm ]
Post subject:  Re: Unknown Escape Character When Opening File

I'll give 1.50 a try and report back.

Author:  craigii [ Mon Jun 06, 2016 3:28 pm ]
Post subject:  Re: Unknown Escape Character When Opening File

That did the trick. Thanks.

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/