【发布时间】:2012-07-06 19:33:46
【问题描述】:
这里是有问题的代码:
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: null
堆栈跟踪:
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 对此感到抱歉。将两者都添加到原始帖子中。
-
您为什么要尝试将 PDF 文件加载到图像处理库中?该文件是否确实存在于该位置?
-
@Oded 我正在尝试将 pdf 转换为 jpg。这段代码取自一个声称可以完成这项工作的示例。该文件确实存在于该位置。
标签: c# .net pdf imagemagick imagemagick.net