I am using one of the samples to convert the first page of the selected PDF to PNG.
public void PDF2PNGFirstPage(string PdfFilePath, string OutputFilePath)
The problem is that the code works only with some PDFs (it can be multipage PDF of course). Some PDF-s throw "input string was not in a correct format". Any ideas?
I have GhostScript 9.10 32bits installed.
public void PDF2PNGFirstPage(string PdfFilePath, string OutputFilePath)
{
int desired_x_dpi = 96;
int desired_y_dpi = 96;
_lastInstalledVersion =
GhostscriptVersionInfo.GetLastInstalledVersion(
GhostscriptLicense.GPL | GhostscriptLicense.AFPL,
GhostscriptLicense.GPL);
_rasterizer = new GhostscriptRasterizer();
_rasterizer.Open(PdfFilePath, _lastInstalledVersion, true);
Image img = _rasterizer.GetPage(desired_x_dpi, desired_y_dpi, 1);
img.Save(OutputFilePath, ImageFormat.Png);
}
Practically the only thing I changed is that i fixed the pgae number for _rasterizer.GetPage, it is constantly set to 1.The problem is that the code works only with some PDFs (it can be multipage PDF of course). Some PDF-s throw "input string was not in a correct format". Any ideas?
I have GhostScript 9.10 32bits installed.