Rank: Member
Groups: Registered
Joined: 2/2/2016(UTC) Posts: 20
|
Rename a PDF file to something like this and it will not load: 新建文本文档.pdf Exception: Unexpected error code. (Patagames.Pdf.Net.Exceptions.PdfiumException) Can you look at this? Edited by user Thursday, March 31, 2016 8:54:27 AM(UTC)
| Reason: Not specified
|
|
|
|
|
|
Rank: Member
Groups: Registered
Joined: 2/2/2016(UTC) Posts: 20
|
Can you please confirm this issue and, if so, provide a fix soon in the next update?
With the latest Pdfium.Net SDK (2.15.1.2595), a blank VS 2010 WinForms .NET Framework 4 project, and only a PdfViewer on the form:
pdfViewer1.LoadDocument("c:\\test\\pdf\\新建文本.pdf");
Results in the exception below. If I change the name 新建文本.pdf to test.pdf and load it, it works fine. I believe any Chinese character in the path may cause it to fail. It's possible that characters from other languages also have this issue.
Patagames.Pdf.Net.Exceptions.PdfiumException was unhandled Message=Unexpected error code. Source=Patagames.Pdf ErrorCode=123 StackTrace: at Patagames.Pdf.Net.PdfDocument.Load(String path, PdfForms forms, String password) at Patagames.Pdf.Net.Controls.WinForms.PdfViewer.LoadDocument(String path, String password) at WindowsFormsApplication2.Form1.Form1_Load(Object sender, EventArgs e) in C:\Users\Administrator\Documents\Visual Studio 2010\Projects\TestPdfiumNet\WindowsFormsApplication2\Form1.cs:line 24 at System.Windows.Forms.Form.OnLoad(EventArgs e) at System.Windows.Forms.Form.OnCreateControl() at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible) at System.Windows.Forms.Control.CreateControl() at System.Windows.Forms.Control.WmShowWindow(Message& m) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ScrollableControl.WndProc(Message& m) at System.Windows.Forms.Form.WmShowWindow(Message& m) at System.Windows.Forms.Form.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) at System.Windows.Forms.SafeNativeMethods.ShowWindow(HandleRef hWnd, Int32 nCmdShow) at System.Windows.Forms.Control.SetVisibleCore(Boolean value) at System.Windows.Forms.Form.SetVisibleCore(Boolean value) at System.Windows.Forms.Control.set_Visible(Boolean value) at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.Run(Form mainForm) at WindowsFormsApplication2.Program.Main() in C:\Users\Administrator\Documents\Visual Studio 2010\Projects\TestPdfiumNet\WindowsFormsApplication2\Program.cs:line 18 at System.AppDomain._nExecuteAssembly(RuntimeAssembly 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, Boolean ignoreSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart() InnerException:
|
|
|
|
|
|
Rank: Administration
Groups: Administrators
Joined: 1/5/2016(UTC) Posts: 1,138
Thanks: 10 times Was thanked: 133 time(s) in 130 post(s)
|
Unfortunately Pdfium uses non-unicode version of CreateFile function so it cannot open such files directly. I can suggest a following workaround: Code:
var stream = System.IO.File.OpenRead(@"d:\0\新建文本文档.pdf");
var doc = PdfDocument.Load(stream);
//....
doc.Dispose();
//Please note you should close the stream strongly after doc.Dicpose() was called.
stream.Close();
Please note you should close the stream strongly after doc.Dicpose() was called.Edited by user Friday, April 8, 2016 1:50:18 AM(UTC)
| Reason: Not specified
|
|
|
|
|
|
Rank: Member
Groups: Registered
Joined: 2/2/2016(UTC) Posts: 20
|
Thanks, the Stream argument works for now. It would still be nice if this is something that could be handled internally by Pdfium.Net SDK in a future update, since there's an assumption of unicode support for file path parameters.
I noticed that saving PDFs doesn't have the same issue. For example, this works: doc.Save("新建文本.pdf", Patagames.Pdf.Enums.SaveFlags.Incremental);
|
|
|
|
|
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.
Important Information:
The Patagames Software Support Forum uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
More Details
Close