Convert PDF to Image without using Ghostscript DLL

前端 未结 4 1961
执念已碎
执念已碎 2020-11-29 03:56

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

4条回答
  •  孤街浪徒
    2020-11-29 04:43

    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 that u used in this function are in there githubs.

提交回复
热议问题