PDF 文档提取解决方案

使用免费的跨平台应用程序和API从PDF文档中提取图像和文本

如何使用 Aspose 库解析 PDF 文件

为什么要使用解析 PDF 文档? 要解析 PDF 文件,我们将使用 Aspose.PDF API,这是一款功能丰富、功能强大且易于使用的文档操作 API。打开 NuGet 软件包管理器,搜索 Aspose.PDF 然后安装。您也可以在软件包管理器控制台中使用以下命令。解析PDF文档是一个与从PDF文件中提取各种信息相关的术语。解析 PDF 文档以提取文本和图像。另外,用于将 PDF 分隔为文本和图像。Aspose.PDF 库允许您从 PDF 和图章中提取文本,从 PDF 中提取图像和字体,从表格和表单中提取数据。

用于解析文档的高代码 API 使用 .NET、.NET Core、Java、C++ 和安卓的 PDF 文件的本机 API

解析 PDF 文件

// Open document
Document pdfDocument = new Document(dataDir + "ExtractTextAll.pdf");

// Create TextAbsorber object to extract text
TextAbsorber textAbsorber = new TextAbsorber();
// Accept the absorber for all the pages
pdfDocument.Pages.Accept(textAbsorber);
// Get the extracted text
string extractedText = textAbsorber.Text;
// Create a writer and open the file
TextWriter tw = new StreamWriter(dataDir + "extracted-text.txt");
// Write a line of text to the file
tw.WriteLine(extractedText);
// Close the stream
tw.Close();