iTextSharp,其实很多时候都是用于生成PDF,但是他读取PDF的能力也不差,使用如下:
1、下载iTextSharp
2、引用动态链接库
解压缩下载的压缩包里面的itextsharp-dll-core.zip,得到itextsharp.dll,在项目中添加引用itextsharp.dll即可
在文件中需要引入以下3个命名空间:
using iTextSharp;
using iTextSharp.text;
using iTextSharp.text.pdf;
3、API的使用方法看代码:
public static void ConvertPdfToWordByText(string pdfFilePath, string wordFilePath)
{
using (iText.Kernel.Pdf.PdfReader reader = new iText.Kernel.Pdf.PdfReader(pdfFilePath))
{
using (iText.Kernel.Pdf.PdfDocument pdfDoc = new iText.Kernel.Pdf.PdfDocument(reader))
{
Spire.Doc.Document doc = new Spire.Doc.Document();
for (int i = 1; i <= pdfDoc.GetNumberOfPages(); i++)
{
iText.Kernel.Pdf.PdfPage page = pdfDoc.GetPage(i);
var strategy =