I need to convert PDF files to images. If the PDF file is multi-page,I just need one image that contains all of the PDF pages.
Is there an open source solution which is not charged like the Acrobat product?
Convert PDF to JPG. Drag and drop a PDF, then convert to JPG, PNG or TIFF file formats. Select a PDF, then convert to JPG, PNG or TIFF file formats. Drag and drop a PDF file to convert it into a JPG file format.
On the print window, in the bottom-left corner, click the drop-down menu and choose “Save as PDF.” Then select the folder to save your PDF in and click “Save.” You now have your image's PDF version available in your selected folder.
First, open your PDF in Preview. Select 'Export' from the file menu. Once again, select 'PNG' as the type of file you wish to save it as. This is a simple method and one I highly recommend, as it lets users make this conversion without third-party software tools.
The thread "converting PDF file to a JPEG image" is suitable for your request.
One solution is to use a third-party library. ImageMagick is a very popular and is freely available too. You can get a .NET wrapper for it here. The original ImageMagick download page is here.
And you also can take a look at the thread "How to open a page from a pdf file in pictureBox in C#".
If you use this process to convert a PDF to tiff, you can use this class to retrieve the bitmap from TIFF.
public class TiffImage { private string myPath; private Guid myGuid; private FrameDimension myDimension; public ArrayList myImages = new ArrayList(); private int myPageCount; private Bitmap myBMP; public TiffImage(string path) { MemoryStream ms; Image myImage; myPath = path; FileStream fs = new FileStream(myPath, FileMode.Open); myImage = Image.FromStream(fs); myGuid = myImage.FrameDimensionsList[0]; myDimension = new FrameDimension(myGuid); myPageCount = myImage.GetFrameCount(myDimension); for (int i = 0; i < myPageCount; i++) { ms = new MemoryStream(); myImage.SelectActiveFrame(myDimension, i); myImage.Save(ms, ImageFormat.Bmp); myBMP = new Bitmap(ms); myImages.Add(myBMP); ms.Close(); } fs.Close(); } }
Use it like so:
private void button1_Click(object sender, EventArgs e) { TiffImage myTiff = new TiffImage("D:\\Some.tif"); //imageBox is a PictureBox control, and the [] operators pass back //the Bitmap stored at that position in the myImages ArrayList in the TiffImage this.pictureBox1.Image = (Bitmap)myTiff.myImages[0]; this.pictureBox2.Image = (Bitmap)myTiff.myImages[1]; this.pictureBox3.Image = (Bitmap)myTiff.myImages[2]; }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With