我在 c# 中从 pdf 中提取图像。
有人建议使用第三方命名空间 Aspose 命名空间。我已经下载了 aspose 并包含在我的项目中作为参考。但问题是我找不到用于提取图像的类 PdfExtractor。
我正在分享有人建议使用 aspose 的链接,并分享我的代码。
这是一个链接
以及我只包含 aspose 的代码
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Aspose;
using Aspose.Pdf;
using Aspose.Pdf.Devices;
using Aspose.Pdf.DOM;
using Aspose.Pdf.Generator;
using Aspose.Pdf.InteractiveFeatures;
using Aspose.Pdf.Structure;
using Aspose.Pdf.Text;
namespace Imageget
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
}
并且链接中建议的类是 PdfExtractor 我也在下面分享它的代码,所以人们不能浪费他的时间去链接。
PdfExtractor objExtractor = new PdfExtractor();
//bind input pdf file
objExtractor.BindPdf("input.pdf");
//extract image with specific mode
objExtractor.ExtractImage(ExtractImageMode.Default);
//check if images extracted and save them one by one
while (objExtractor.HasNextImage()) {
objExtractor.GetNextImage(DateTime.Now.Ticks.ToString() + ".jpg");
}