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

error opening pdfs: PdfReaderException - UNEXPECTED ERROR
https://forum.pdfsharp.net/viewtopic.php?f=2&t=151
Page 1 of 1

Author:  kon_t [ Mon May 28, 2007 9:33 pm ]
Post subject:  error opening pdfs: PdfReaderException - UNEXPECTED ERROR

I have added a simple 'concatenate files' operation to an application, based on the code in the pdfsharp samples. Code appears to be working fine for many pdf docs.

However when attempting to open some dpf files [using PdfReader.Open(file, PdfDocumentOpenMode.Import)] a PdfSharp.Pdf.IO.PdfReaderException is thrown by the pdfsharp code.

Acrobat reader 8 opens the files without any problems.

As a test I copied some of the problem pdf files to the folder used by the concatenate documents pdfsharp sample & ran the sample. It stopped with the same exception. The error & stac trace from the sample app are included below. I did not change the saple source.k

Does anyone know about this error?
can anyone give me some clues as to how to go about fixing it?
I am new to pdf files, but am happy to work on a fix for the library (if required).

Thanks in advance
Kon Tantos

Error & stack trace from vs2005.

PdfSharp.Pdf.IO.PdfReaderException was unhandled
Message="UNEXPECTED ERROR while formatting message: System.Resources.MissingManifestResourceException: Could not find any resources appropriate for the specified culture or the neutral culture. Make sure \"PdfSharp.Resources.Messages.resources\" was correctly embedded or linked into assembly \"PdfSharp\" at compile time, or that all the satellite assemblies required are loadable and fully signed.\r\n at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo culture, Boolean createIfNotExists, Boolean tryParents)\r\n at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo culture, Boolean createIfNotExists, Boolean tryParents)\r\n at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo culture, Boolean createIfNotExists, Boolean tryParents)\r\n at System.Resources.ResourceManager.GetString(String name, CultureInfo culture)\r\n at System.Resources.ResourceManager.GetString(String name)\r\n at PdfSharp.PSSR.GetString(PSMsgID id) in D:\\_Development\\Research\\PDFSharp-0.9.653+MigraDocLite-1.2.1930\\PDFsharp\\PdfSharp\\PdfSharp\\PSSR.cs:line 108\r\n at PdfSharp.PSSR.Format(PSMsgID id, Object[] args) in D:\\_Development\\Research\\PDFSharp-0.9.653+MigraDocLite-1.2.1930\\PDFsharp\\PdfSharp\\PdfSharp\\PSSR.cs:line 72"
Source="PdfSharp"
StackTrace:
at PdfSharp.Pdf.IO.Parser.ReadSymbol(Symbol symbol) in D:\_Development\Research\PDFSharp-0.9.653+MigraDocLite-1.2.1930\PDFsharp\PdfSharp\PdfSharp.Pdf.IO\Parser.cs:line 538
at PdfSharp.Pdf.IO.Parser.ReadTrailer() in D:\_Development\Research\PDFSharp-0.9.653+MigraDocLite-1.2.1930\PDFsharp\PdfSharp\PdfSharp.Pdf.IO\Parser.cs:line 708
at PdfSharp.Pdf.IO.PdfReader.Open(Stream stream, String password, PdfDocumentOpenMode openmode, PdfPasswordProvider passwordProvider) in D:\_Development\Research\PDFSharp-0.9.653+MigraDocLite-1.2.1930\PDFsharp\PdfSharp\PdfSharp.Pdf.IO\PdfReader.cs:line 275
at PdfSharp.Pdf.IO.PdfReader.Open(String path, String password, PdfDocumentOpenMode openmode, PdfPasswordProvider provider) in D:\_Development\Research\PDFSharp-0.9.653+MigraDocLite-1.2.1930\PDFsharp\PdfSharp\PdfSharp.Pdf.IO\PdfReader.cs:line 200
at PdfSharp.Pdf.IO.PdfReader.Open(String path, PdfDocumentOpenMode openmode) in D:\_Development\Research\PDFSharp-0.9.653+MigraDocLite-1.2.1930\PDFsharp\PdfSharp\PdfSharp.Pdf.IO\PdfReader.cs:line 172
at ConcatenateDocuments.Program.Variant1() in D:\_Development\Research\PDFSharp-0.9.653+MigraDocLite-1.2.1930\PDFsharp\Samples C#\ConcatenateDocuments\Program.cs:line 87
at ConcatenateDocuments.Program.Main(String[] args) in D:\_Development\Research\PDFSharp-0.9.653+MigraDocLite-1.2.1930\PDFsharp\Samples C#\ConcatenateDocuments\Program.cs:line 49
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()

Author:  Stefan Lange [ Thu Jun 07, 2007 8:50 am ]
Post subject: 

Hi,

the UNEXPECTED ERROR while formatting message... comes because a satellite assembly with the errors messages was not found. This may be a build error.

The actual error is in PdfSharp.Pdf.IO.Parser.ReadSymbol called from PdfSharp.Pdf.IO.Parser.ReadTrailer. I cannot guess what happens here. Please send me the PDF (using the e-mail address published in the source code) and I will take a look at it.

Author:  acorn98 [ Thu Oct 30, 2008 2:31 am ]
Post subject: 

Hi Stefan,

Did you ever get to the bottom of this problem? I am getting the same error.

Author:  canuckotter [ Tue Sep 27, 2016 8:02 pm ]
Post subject:  Re: error opening pdfs: PdfReaderException - UNEXPECTED ERRO

I'm getting a similar error with 1.50 beta3. In my case, the fault that starts the chain is that I'm trying to open a secured PDF without providing a password or anything. That generates a PdfReaderException. The problem is that the PdfReaderException is trying to use the PdfSharp-gdi DLL's Resources\Messages.restext resources... only they don't exist. And it seems as though the reason they don't exist is pretty simple - the Build Action for both the Messages.restext and the Messages.de.restext is set to "None" in the source code I have. I changed that to "Embedded Resource" and rebuilt and tried again and got the PdfReaderException as expected, which I can handle cleanly.

Is there a process by which I can submit my suggested change? In this particular case it's probably not worth it :wink: but if I find more things in the future that I could help address, I'd prefer to feed fixes back rather than having to maintain my own version of the codebase... :)

Author:  TH-Soft [ Tue Sep 27, 2016 9:50 pm ]
Post subject:  Re: error opening pdfs: PdfReaderException - UNEXPECTED ERRO

Hi!
canuckotter wrote:
Is there a process by which I can submit my suggested change?
Bug fixes posted on the forum will be evaluated and will get into the codebase, so posting here is a good way.

The resources bug was fixed some time ago.
A new release is overdue but I cannot give any ETA.

Author:  Gerben Vos [ Tue Oct 04, 2016 3:35 pm ]
Post subject:  Re:

Stefan Lange wrote:
The actual error is in PdfSharp.Pdf.IO.Parser.ReadSymbol called from PdfSharp.Pdf.IO.Parser.ReadTrailer. I cannot guess what happens here.


If the issue of the original poster from 2007 has not been fixed yet in 1.50_beta3, it may be worth trying some of the fixes I recently posted on the "Bug fixes" forum, for example this one: viewtopic.php?f=3&t=3451 .

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