Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert PDF files to images

Tags:

c#

image

pdf

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?

like image 648
loveForEver Avatar asked May 28 '14 07:05

loveForEver


People also ask

How do I convert PDF to JPG for free?

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.

How do I save a downloaded PDF as a picture?

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.

How do I convert a PDF file to PNG?

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.


1 Answers

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.

  • Convert PDF pages to image files using the Solid Framework Convert PDF pages to image files using the Solid Framework (dead link, the deleted document is available on Internet Archive).
  • Convert PDF to JPG Universal Document Converter
  • 6 Ways to Convert a PDF to a JPG Image

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]; } 
like image 171
Gaurav Deochakke Avatar answered Oct 05 '22 04:10

Gaurav Deochakke