How to convert PDF to images using C # and ImageMagick?

I would like to convert a PDF file to .GIF using C # and magicknet.dll. I added a link to the MagickNet Dll file to my project.

MagickNet.Magick.Init(); MagickNet.Image img = new MagickNet.Image("d:/aa.pdf"); img.Write("d:/bb.gif"); MagickNet.Magick.Term(); img.Dispose(); 
  System.Runtime.InteropServices.SEHException was unhandled by user code
   Message = "External component has thrown an exception."
   Source = "ImageMagickNET"
   ErrorCode = -2147467259
   Stacktrace:
        at Magick.Image. {ctor} (Image *, basic_string \, std :: allocator> *)
        at ImageMagickNET.Image..ctor (String imageSpec)
        at Test1._Default.Button1_Click (Object sender, EventArgs e) in C: \ Users \ PANKAJ \ Documents \ Visual Studio 2008 \ Projects \ Test1 \ Test1 \ Default.aspx.cs: line 31
        at System.Web.UI.WebControls.Button.OnClick (EventArgs e)
        at System.Web.UI.WebControls.Button.RaisePostBackEvent (String eventArgument)
        at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent (String eventArgument)
        at System.Web.UI.Page.RaisePostBackEvent (IPostBackEventHandler sourceControl, String eventArgument)
        at System.Web.UI.Page.RaisePostBackEvent (NameValueCollection postData)
        at System.Web.UI.Page.ProcessRequestMain (Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
   InnerException: 
+4
source share
1 answer

ImageMagick requires GhostScript to interpret PDF files. If you want, you can directly call the GhostScript DLL (contact me through my profile, I will send you a C # wrapper)

Alternatively, you can use the GhostScript command line or a commercial third-party component, such as the PDF libraries from Tall Components.

+1
source

Source: https://habr.com/ru/post/1299937/


All Articles