image - Save pdf to jpeg using c# -
i need convert pdf file jpeg using c#. , solution (library) have free.
i have searched lot of information seems don't nothing clear.
i tried itextsharp , pdfbox (but this, pdf2image java, think) no success.
i tried extract images pdf individually, have error of invalid parameters when try extract images... seems have strange encoding.
anyone can recommend me library save pdf jpeg? examples appreciated too.
thanks!
solution: how convert pdf image using c#
- go to: http://www.codeproject.com/kb/cs/ghostscriptusewithcsharp.aspx
- download de library
- follow steps in web
add code application, (very simple):
//transform pdf jpg pdftoimage.pdfconvert pp = new pdfconvert(); pp.outputformat = "jpeg"; //format pp.jpegquality = 100; //100% quality pp.resolutionx = 300; //dpi pp.resolutiony = 300; pp.firstpagetoconvert = 1; //pages want pp.lastpagetoconvert = 1; pp.convert(path_pdf+ "report.pdf", path_image + "name.jpg");
the library pdfiumviewer might helpful here. available nuget.
- create new winforms app. add nuget "pdfiumviewer" it.
- this add 2 native dll's named "pdfium.dll" in folders x86 , x64 project. set "copy output directory" "copy always".
try out following code (change paths suit setup).
try { using (var document = pdfiumviewer.pdfdocument.load(@"input.pdf")) { var image = document.render(0, 300, 300, true); image.save(@"output.png", imageformat.png); } } catch (exception ex) { // handle exception here; }
edit 2: changed code show page index 0 based pointed out in comment s.c. below
edit 1: updated solution have tried pdfsharp?
Comments
Post a Comment