Convert PDF to JPG / Images without using a specific C# Library [closed]

老子叫甜甜 提交于 2019-12-18 11:53:56

问题


is there a free C# library (.dll) to convert PDF to images ?

I tried this one :

https://code.google.com/p/lib-pdf/

But it doesn't work, I got this error :

  Could not load file or assembly 'libpdf.DLL' or one of its dependencies. The specified    module could not be found.

iTextSharp doesn't implement a function like that either..

EDIT:

I didn't use ghost scrpit because you had to install it before on the computer

But now I found a solution : if you load manualy the dll it works

http://ghostscriptnet.codeplex.com/discussions/465418

    public void PDFToImage(string file, string outputPath, int dpi)
    {
        string path = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);

        Ghostscript.NET.Rasterizer.GhostscriptRasterizer rasterizer = null;
        Ghostscript.NET.GhostscriptVersionInfo vesion = new Ghostscript.NET.GhostscriptVersionInfo(new Version(0, 0, 0), path + @"\gsdll32.dll", string.Empty, Ghostscript.NET.GhostscriptLicense.GPL);

        using (rasterizer = new Ghostscript.NET.Rasterizer.GhostscriptRasterizer())
        {
            rasterizer.Open(file, vesion, false);

            for (int i = 1; i <= rasterizer.PageCount; i++)
            {
                string pageFilePath = Path.Combine(outputPath, Path.GetFileNameWithoutExtension(file) + "-p" + i.ToString() + ".jpg");

                Image img = rasterizer.GetPage(dpi, dpi, i);
                img.Save(pageFilePath, ImageFormat.Jpeg);
            }

           rasterizer.Close();
       }
   }

来源:https://stackoverflow.com/questions/22505502/convert-pdf-to-jpg-images-without-using-a-specific-c-sharp-library

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!