Quantcast
Channel: Ghostscript.NET
Viewing all articles
Browse latest Browse all 393

New Post: some PDFs cannot be converted

$
0
0
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)
    {
        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.

Viewing all articles
Browse latest Browse all 393

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>