解壓縮下載的PDFBox,找到其中的Bin目錄,需要在項(xiàng)目中添加引用的dll文件有: IKVM.GNU.Classpath.dll PDFBox-0.7.3.dll FontBox-0.1.0-dev.dll IKVM.Runtime.dll 將以上4個(gè)文件引用到項(xiàng)目中,在文件中需要引入以下2個(gè)命名空間: using org.pdfbox.pdmodel; using org.pdfbox.util;
using org.pdfbox.pdmodel;
using org.pdfbox.util;
public void pdf2txt(FileInfo file,FileInfo txtfile)
{PDDocument doc = PDDocument.load(file.FullName);PDFTextStripper pdfStripper = new PDFTextStripper();string text = pdfStripper.getText(doc);StreamWriter swPdfChange = new StreamWriter(txtfile.FullName, false, Encoding.GetEncoding("gb2312"));swPdfChange.Write(text);swPdfChange.Close();
}
解壓縮下載的壓縮包里面的itextsharp-dll-core.zip,得到itextsharp.dll,在項(xiàng)目中添加引用itextsharp.dll即可 在文件中需要引入以下3個(gè)命名空間: using iTextSharp; using iTextSharp.text; using iTextSharp.text.pdf;