I´m trying to get an image from PDF with Ghostcript.NET in C#. I have installed Ghostscript dll already (both 32 and 64 bit) and added the reference in the proyect. I´ve just taken the example for the web and it gives me an error (img was null) and i don´t know why. This is the code:
`using System;
using Ghostscript.NET.Rasterizer;
using System.IO;
using Ghostscript.NET;
using System.Drawing.Imaging;
namespace StackOverflowExample
{
class Program
{
static void Main(string[] args)
{
int desired_dpi = 96;
string inputPdfPath = @"C:\Users\orubio\Documents\Pruebas\test.pdf";
string outputPath = @"C:\Users\orubio\Documents\Pruebas\";
GhostscriptVersionInfo gvi = new GhostscriptVersionInfo(@"C:\Program Files (x86)\gs\gs9.56.1\bin\gsdll32.dll");
using (var rasterizer = new GhostscriptRasterizer())
{
rasterizer.Open(inputPdfPath, gvi, false);
for (var pageNumber = 1; pageNumber <= rasterizer.PageCount; pageNumber++)
{
var pageFilePath = Path.Combine(outputPath, string.Format("Page-{0}.png", pageNumber));
var img = rasterizer.GetPage(desired_dpi, pageNumber);
img.Save(pageFilePath, ImageFormat.Png);
Console.WriteLine(pageFilePath);
}
}
}
}
}`
Ty everyone :D