Convert PDF to Image without using Ghostscript DLL

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.

Leave a Comment