PDF 文件提取解決方案

使用免費的跨平臺應用程式和 API 從 PDF 文件中提取圖像和文字

如何使用庫解析 PDF 檔

為什麼要使用解析 PDF 文檔? 要解析 PDF 文件,我們將使用 [Aspose.PDF](https://products.aspose.com/pdf) API,這是一個功能豐富、功能強大且易於使用的文檔操作 API。打開 [NuGet](https://www.nuget.org/packages/aspose.pdf) 包管理器,搜索“aspose.PDF然後安裝。您也可以從程式包管理器主控台使用以下命令。解析PDF文檔是一個術語,用於從PDF檔中提取各種資訊。解析PDF文檔以提取文本和圖像。此外,用於將PDF作為文本和圖像分開。Aspose.PDF庫允許您從PDF和圖章中提取文字,從PDF中提取圖像和字體,從表格和表單中提取數據。

用於解析文檔的高代碼 API 使用 .NET、.NET Core、Java、C++和安卓的 PDF 檔的本機 API

解析檔

// 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();