這裏是有問題的代碼:爲什麼我無法用ImageMagickNet打開PDF文件?
MagickNet.InitializeMagick();
ImageMagickNET.Image image = new ImageMagickNET.Image(@"C:\temp.pdf");
image.Quality = 100;
image.CompressType = ImageMagickNET.CompressionType.LosslessJPEGCompression;
image.Write(@"C:\temp.jpg");
我相當肯定此代碼應工作,但我得到的信息非常例外:External component has thrown an exception.
此異常就行拋出:ImageMagickNET.Image image = new ImageMagickNET.Image(@"C:\temp.pdf");
的InnerException:空
堆棧跟蹤:
at Magick.Image.{ctor}(Image* , basic_string<char\,std::char_traits<char>\,std::allocator<char> >*)
at ImageMagickNET.Image..ctor(String imageSpec)
at WindowsFormsApplication1.Form1.ReadQRCode(String doc) in C:\Users\me\Documents\Visual Studio 2010\Projects\WindowsFormsApplication1\WindowsFormsApplication1\Form1.Designer.cs:line 126
at WindowsFormsApplication1.Form1.seperatePDFsInOrder(String fileName) in C:\Users\me\Documents\Visual Studio 2010\Projects\WindowsFormsApplication1\WindowsFormsApplication1\Form1.Designer.cs:line 109
at WindowsFormsApplication1.Form1.InitializeComponent() in C:\Users\me\Documents\Visual Studio 2010\Projects\WindowsFormsApplication1\WindowsFormsApplication1\Form1.Designer.cs:line 44
at WindowsFormsApplication1.Form1..ctor() in C:\Users\me\Documents\Visual Studio 2010\Projects\WindowsFormsApplication1\WindowsFormsApplication1\Form1.cs:line 16
at WindowsFormsApplication1.Program.Main() in C:\Users\me\Documents\Visual Studio 2010\Projects\WindowsFormsApplication1\WindowsFormsApplication1\Program.cs:line 20
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()
任何人都有任何想法,我可能會做錯嗎?
任何內部異常?堆棧跟蹤? – Oded 2012-07-06 19:35:28
@Oded對不起。添加到原始帖子。 – PFranchise 2012-07-06 19:38:10
你爲什麼要將PDF文件加載到圖像處理庫中?該文件是否確實存在於該位置? – Oded 2012-07-06 19:39:37