zuloops.blogg.se

Convert pdf to image file
Convert pdf to image file












convert pdf to image file

#CONVERT PDF TO IMAGE FILE INSTALL#

If you want to convert PDF file into image file in production server or any other server, then you should install the Ghostscript (32/64 bit) for that server otherwise it will show you an error.But, if you want to convert pdf file into jpg/jpeg, then in place of png, please write jpg/jpeg. In the above example, I converted the PDF file into png image file.Please see above in the picture like resolution etc.Īnd in the img.Process() actually the pdf is converting to png image.Īfter Conversion the PdfFolder looks like this, Similarly I added some more properties for that object. In the above line I am adding the OutputFile whose extension is “.png” In the above line I am adding the SourceFile whose extension is “.pdf”. After that I set the properties for that object. First, I created the object of GhostscriptPngDevice which will used to convert the Pdf to Image. Here, first I am checking whether that image exists in the ImgFolder or not. Here, I am calling Pdf2ImageConversion method which contains 2 parameters in which the first parameter is the name of the file and the second parameter is PdfFolder path. First, I am storing the original PDF in PdfFolder. If we haven't installed the Ghostscript in our computer and are trying to run the application directly, then we can encounter the error which is shown in the below picture,Īfter that, I click on the Submit button.The reason behind is that while converting the PDF file to an image file, we need Ghostscript in our computer and to access the Ghostscript properties, we have to install it in our Visual Studio Solution. You might get confused here that if I already have installed the Ghostscript in my Solution, then what is the need of installing it again. The second step is exporting the bitmap graphics to the image files, such as. Please refer this link and always install and use the latest version. In most case, there are only two steps to save PDF page to an image file: The first step is loading PDF document and converting it to the System Bitmap object in the memory. Please install Ghostscript in your computer according to its bit rate, that is32/64 bit.Ghostscript is an interpreter for the PostScript language and for PDF.įirst, we need to add Ghostscript in our solution by going to the Package Manager Console or we can add its dll file directly in reference of our Solution.Īfter you have installed the GhostScript in your application, please check in your reference whether it exists or not.Īfter that, design your UI like the below image.Īnd, create two new folders in that Solution with the names - PdfFolder and ImgFolder respectively.














Convert pdf to image file