从pdf文件中提取图像 [英] extract images from pdf files

查看:84
本文介绍了从pdf文件中提取图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一个代码(在.net中)从pdf文件中提取图像。

I am looking for a code (in .net) to extract images from pdf files.

推荐答案

我想展示一种从PDF中提取图像的方法通过Spire.PDF.please使用VB.NET下载Spire.PDF dll。



进口系统

Imports System.Collections.Generic

Imports System.Drawing

Imports System.Drawing.Imaging

Imports Spire.Pdf





命名空间ExtractImage

朋友类提取

共享子主(ByVal args()为字符串)

'加载文件

Dim doc As New PdfDocument()

doc.LoadFromFile(D:\work\My Documents\Employee Information.pdf)



昏暗的图像作为IList(图像)=新列表(图像)()



For每页作为PdfPageBase在doc.Pages

对于每个图像作为图像在页面.ExtractImages()

images.Add(图像)

下一张图片

下一页



doc.Close()



'保存图片

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)

下一张图片



系统。 Diagnostics.Process.Start(Extract0.png)

End Sub

结束类

结束命名空间
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


您是否需要将图像提取为PDF或其他图像格式?

如果是PDF,只需使用ITextSharp或PDFSharp。

如果您需要光栅化,请使用此 http://code.google.com/p/mupdf-converter/ [ ^ ]
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/[^]

谢谢大家,我决定使用这个解决方案:



简单且免费的PDF到图像转换 [ ^ ]



虽然有一些限制,但它解决了我的问题。



再次感谢。
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.


这篇关于从pdf文件中提取图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆