PdfExtractor

概述

PdfExtractor 是 Aspose.PDF FOSS 中用于 .NET 的类。继承自:IDisposable。

用于从 PDF 文档中提取文本和图像的门面。

此类提供了 29 个方法,用于在 .NET 程序中处理 PdfExtractor 对象。可用的方法包括:BindPdf、Close、Dispose、ExtractAttachment、ExtractImage、ExtractText、GetAttachNames、GetAttachment、GetAttachmentInfo、GetNextImage、GetNextPageText、GetText,以及另外 3 个方法。安装 Aspose.PDF FOSS for .NET 包后,所有公共成员对任何 .NET 应用程序均可访问。属性:EndPage、ExtractImageMode、ExtractTextMode、IsBidi、Password、Resolution,以及另外 2 个。

属性

名称类型访问描述
StartPageint读写提取的起始页(从1开始)。
EndPageint读写提取的结束页(从1开始)。
ExtractTextModeint读写文本提取模式。
ExtractImageModeExtractImageMode读写图像提取策略。
Resolutionint读写图像提取的渲染分辨率(DPI)。
IsBidibool读取当最近提取的文本包含从右到左的脚本序列(希伯来语、阿拉伯语、叙利亚语、塔那语等),即为真。
Passwordstring?读写绑定加密 PDF 时使用的密码。
TextSearchOptionsAspose.Pdf.Text.TextSearchOptions读写在 ExtractText() 期间应用的文本搜索选项。

方法

签名描述
PdfExtractor()在此 PdfExtractor 实例上调用 PdfExtractor。
PdfExtractor(document: Document)在此 PdfExtractor 实例上调用 PdfExtractor(document)。
BindPdf(inputFile: string)在此 PdfExtractor 实例上调用 BindPdf(inputFile)。
BindPdf(document: Document)在此 PdfExtractor 实例上调用 BindPdf(document)。
BindPdf(inputStream: Stream)在此 PdfExtractor 实例上调用 BindPdf(inputStream)。
ExtractText()使用 TextAbsorber 遍历绑定文档的每一页,并将提取的文本连接起来。
ExtractText(outputFile: string)从绑定的 PDF 中提取文本并保存到指定文件(UTF-16 LE 字节)。
ExtractText(encoding: Encoding)使用给定的编码从绑定的 PDF 中提取文本。
GetText(outputStream: Stream)将提取的文本以字节形式写入 outputStream,使用最近一次 ExtractText(Encoding) 调用设置的编码(默认是 UTF-16 LE)。
GetText(outputStream: Stream, filterNotAscii: bool)将提取的文本以字节形式写入,可选地先删除非 ASCII 码点。
GetText(outputFile: string)将提取的文本写入给定的文件路径。
HasNextPageText()如果通过 GetNextPageText 可以获取到另一页的文本,则为 true。
GetNextPageText(outputFile: string)将下一页的文本写入给定的文件路径(UTF-16 LE 字节)。
GetNextPageText(outputStream: Stream)将下一页的文本写入给定的流(UTF-16 LE 字节)。
ExtractImage()在此 PdfExtractor 实例上调用 ExtractImage。
ExtractImage(outputDirectory: string)将每个图像提取到给定目录,JPEG 源使用 image_N.jpg 命名文件,其他情况使用 image_N.png。
HasNextImage()当 GetNextImage(string) 仍有未写入的图像时为 true。
GetNextImage(outputStream: Stream)在此 PdfExtractor 实例上调用 GetNextImage(outputStream)。
GetNextImage(outputFile: string)在此 PdfExtractor 实例上调用 GetNextImage(outputFile)。
GetNextImage(outputStream: Stream, format: System.Drawing.Imaging.ImageFormat)在此 PdfExtractor 实例上调用 GetNextImage(outputStream, format)。
GetNextImage(outputFile: string, format: System.Drawing.Imaging.ImageFormat)在此 PdfExtractor 实例上调用 GetNextImage(outputFile, format)。
ExtractAttachment()选择绑定文档中的所有嵌入文件;随后使用 GetAttachment(string) 将它们全部写入。
ExtractAttachment(attachmentFileName: string)按名称选择单个嵌入文件进行提取。
GetAttachNames()绑定文档中每个嵌入文件的名称。
GetAttachmentInfo()FileSpecification 条目对应绑定文档中的每个嵌入文件。
GetAttachment()返回所选附件的内容,格式为 MemoryStreams(未明确选择时返回所有附件)。
GetAttachment(outputPath: string)将所选附件(未明确选择时为全部)写入 outputPath 目录,每个附件为一个文件,文件名使用其原始文件名。
Close()对该 PdfExtractor 实例调用 Close 方法。
Dispose()对该 PdfExtractor 实例调用 Dispose 方法。

另请参阅

 中文