Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert PDF to Image without using Ghostscript DLL

Tags:

c#

Is there any way, I can convert HTML Document (file not URL) to Image, or PDF to image?

I am able to do the above using Ghostscript DLL , Is there any other way , I can do it, without using the Ghostscript DLL?

I am developing a C# Windows Application.

like image 615
Deepak Jena Avatar asked Oct 11 '12 03:10

Deepak Jena


People also ask

Does ImageMagick use GhostScript?

ImageMagick uses GhsotScript for that. So you can't do it with ImageMagick without GhostScript. You can use GhostScript to render PDF to JPG from command line running gswin32.exe (even without ImageMagic) or from your software using gsdll32.

How do I convert a PDF to a DLL?

To show PDF into DLL, you simply have to add a sample, alter it, if required, and save all modifications. The uploading strategies are vast and contain searching a file from the unit, importing it from your cloud, by way of a secure URL, e-mail request, or obtaining a template in the pdfFiller's kind library.


1 Answers

the best and free nuget package that you can save every page of your Pdf to png and with custom resilution Docnet.core this can be use in the .net core project.

they have github and nice examples but here i want to add my code for reading en pdf with more that one page

        string webRootPath = _hostingEnvironment.WebRootPath;
        string fullPath = webRootPath + "/uploads/user-manual/file.pdf";
        string fullPaths = webRootPath + "/uploads/user-manual";

        using (var library = DocLib.Instance)
        {
            using (var docReader = library.GetDocReader(fullPath, 1080, 1920))
            {
                for (int i = 1; i < docReader.GetPageCount(); i++)
                {
                    using (var pageReader = docReader.GetPageReader(i))
                    {
                        var bytes = EmailTemplates.GetModifiedImage(pageReader);

                        System.IO.File.WriteAllBytes(fullPaths+"/page_image_" +i+".png", bytes);
                    }
                }

            }
        }

Other functions you can find in thier github repo.

like image 112
Mohammad Hassani Avatar answered Sep 27 '22 22:09

Mohammad Hassani