从 PDF 文件中提取图像

使用页面资源

以下代码片段也适用于 Aspose.PDF.Drawing 库。

图像保存在每个页面的 Resources 集合的 Images 集合中。要提取特定页面,然后使用图像的特定索引从 Images 集合中获取图像。

图像的索引返回一个 XImage 对象。该对象提供一个 Save 方法用于保存提取的图像。以下代码片段展示了如何从 PDF 文件中提取图像。

使用 ImagePlacementAbsorber

随着 Aspose.PDF for .NET 7.0.0 的发布,我们引入了名为 ImagePlacementImagePlacementAbsorberImagePlacementCollection 的类,这些类提供与上述类类似的功能,以获取 PDF 文档中图像的分辨率和位置。

  • ImagePlacementAbsorber 执行图像使用搜索,作为 ImagePlacement 对象集合。
  • ImagePlacement 提供成员 Resolution 和 Rectangle,返回实际的图像放置值。

下一个代码片段也适用于 Aspose.Drawing 库。