this is my first question here so please don't be to harsh on me :) Anyway, let's get right to it:
For an application I need to convert a PDF file to an Image file (Specific format doesn't matter but preferably png or jpg). To get this done, I try to use ImageMagick but when I try to convert anything, it will throw an error. Now after some research I came to the conclusion I needed to have Ghostscript installed, which I tried to get from the NuGet package manager integrated in Visual Studio 2017. Anyway, when I try to install said package, it throws the following error:
Severity Code Description Project File Line Suppression >State Error Failed to add reference to 'gsdll32'. Please make sure that the file is accessible, and that it is a valid >assembly or COM component.
I'm trying to accomplish this using Visual Studio 2017 with C#. The API's I am using are:
+Magick.NET-Q16-AnyCPU V7.11.1
+GhostScriptSharp V1.3.1.4
+Ghostscript V9.2.0 (Throws error)
In case it is required to understand what I am trying, here is the code that I am trying to compile:
using ImageMagick.Configuration;
using ImageMagick.Defines;
using ImageMagick.ImageOptimizers;
using ImageMagick;
using GhostscriptSharp;
using GhostscriptSharp.Settings;
public MagickImageCollection PDFOutput;
public Image Current;
public org.pdfclown.documents.Page CurrentPage;
private void BtnConvert_Click(object sender, EventArgs e)
{
if(openFileDialog1.ShowDialog() == DialogResult.OK)
{
try
{
ImageMagick.MagickNET.Initialize();
MagickReadSettings Settings = new MagickReadSettings();
Settings.Density = new Density(300, 300);
Settings.Format = MagickFormat.Jpg;
using (MagickImageCollection Images = new MagickImageCollection())
{
Images.Add(openFileDialog1.FileName);
int Page = 1;
int i = 0;
foreach(MagickImage Image in Images)
{
Image.Write("FilePage #" + Page);
PDFOutput[i] = Image;
Page++;
i++;
}
MessageBox.Show(PDFOutput.Count.ToString());
}
}
catch(Exception E)
{
MessageBox.Show(E.Message);
}
Am I missing something regarding the GhostScipt install? Does it only work when downloaded directly from the GhostScript website?
I hope that I have provided enough context to my problem and I'll be looking forward to any answers I may get on this.
Many thanks in advance!!
Kind Regards, Melvin