Click here to Skip to main content
15,881,898 members
Please Sign up or sign in to vote.
1.33/5 (2 votes)
See more:
I am looking for a code (in .net) to extract images from pdf files.
Posted
Comments
Sandeep Mewara 14-May-12 4:45am    
Did you try anything by yourself? (Apart form searching any code!)

I want to show a method to extract image from PDF by using VB.NET via Spire.PDF.please download Spire.PDF dll for this.

Imports System
Imports System.Collections.Generic
Imports System.Drawing
Imports System.Drawing.Imaging
Imports Spire.Pdf


Namespace ExtractImage
Friend Class Extract
Shared Sub Main(ByVal args() As String)
'Load File
Dim doc As New PdfDocument()
doc.LoadFromFile("D:\work\My Documents\Employee Information.pdf")

Dim images As IList(Of Image) = New List(Of Image)()

For Each page As PdfPageBase In doc.Pages
For Each image As Image In page.ExtractImages()
images.Add(image)
Next image
Next page

doc.Close()

'Save Image
Dim index As Integer = 0
For Each image As Image In images
Dim imageFileName As StringString = String.Format("Extract{0}.png", index)
index += 1
image.Save(imageFileName, ImageFormat.Png)
Next image

System.Diagnostics.Process.Start("Extract0.png")
End Sub
End Class
End Namespace
 
Share this answer
 
Comments
amirparsiparsi 14-May-12 2:09am    
It seems Spire.PDF.dll is not free. Is it?
Do you need extract the images to PDF or another image format?
If it is to PDF just use ITextSharp or PDFSharp.
If you need to rasterize you have this http://code.google.com/p/mupdf-converter/[^]
 
Share this answer
 
Thanks everybody, I decided to use this solution:

Simple and Free PDF to Image Conversion[^]

Although is has some limitations, it solves my problem for this time.

Thanks again.
 
Share this answer
 
v2
MigraDoc + PDFSharp can do that.
http://www.pdfsharp.net/wiki/ExportImages-sample.ashx[^]

The library is free, you can use it in open source and closed source applications. It also can be found in NuGet packages inside Visual Studio.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900