Sarmad Yousif

Sarmad Yousif

  • NA
  • 128
  • 7k

GhostScript convert PDF to image

Feb 6 2020 12:27 PM
I followed this tutorial :
https://www.c-sharpcorner.com/blogs/convert-pdf-file-into-image-filepngjpgjpeg-using-ghostscript
 
public void ExtracImagesFromPdf(string fileNameResultDirectory)
{
GhostscriptPngDevice img = new GhostscriptPngDevice(GhostscriptPngDeviceType.Png16m);
img.GraphicsAlphaBits = GhostscriptImageDeviceAlphaBits.V_4;
img.TextAlphaBits = GhostscriptImageDeviceAlphaBits.V_4;
img.ResolutionXY = new GhostscriptImageDeviceResolution(200, 200);
img.InputFiles.Add(fileNameResultDirectory);
//img.Pdf.FirstPage = 1;
//img.Pdf.LastPage = 1;
img.PostScript = string.Empty;
img.OutputPath = @"C:\Users\name\Desktop\images\Result";
img.Process();
 }
I get this error: Ghostscript.NET.GhostscriptAPICallException: 'An error occured when call to 'gsapi_init_with_args' is made: -100'
 
My PDF has more than page. 

Answers (4)