如何从C#中的PDF文件中提取图像,文本和字体细节 [英] How to extract images, text and font details from PDF file in C#
本文介绍了如何从C#中的PDF文件中提取图像,文本和字体细节的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在开发一个用于PDF比较的C#工具,它将比较两个PDF文件。
为此,我需要提取PDF格式,如图像,文本,字体大小,书签等。
任何想法如何在C#中执行此操作。
在此先感谢,
Kane
Hi,
I am developing a tool in C# for PDF comparison which will compare two PDF files.
For this I need to extract the PDF contect such as images, text, font size, bookmarks, etc.
Any idea how to do this in C#.
Thanks In Advance,
Kane
推荐答案
要从PDF中提取文本/图像,我建议使用PDF sharp或Itextsharp。
下载itextsharp dlls
http://sourceforge.net/projects/itextsharp/ [ ^ ]
Itextsharp的文档api
http://www.afterlogic.com/mailbee-net/docs-itextsharp/ [ ^ ]
从itextsharp中的所有页面获取文本
To extract text/images from a PDF i would suggest using either PDF sharp or Itextsharp.
Download itextsharp dlls
http://sourceforge.net/projects/itextsharp/[^]
A documentation for Itextsharp api
http://www.afterlogic.com/mailbee-net/docs-itextsharp/[^]
Get text from all pages in itextsharp
public static string GetTextFromAllPages(String pdfPath)
{
PdfReader reader = new PdfReader(pdfPath);
StringWriter output = new StringWriter();
for (int i = 1; i <= reader.NumberOfPages; i++)
output.WriteLine(PdfTextExtractor.GetTextFromPage(reader, i, new SimpleTextExtractionStrategy()));
return output.ToString();
}
如何从PDF中提取图像并保存到文件
http:// kishor-naik- dotnet.blogspot.com/2011/01/cnet-extract-image-from-pdf-file.html [ ^ ]
这篇关于如何从C#中的PDF文件中提取图像,文本和字体细节的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文