PDFBOX 读取数据报错--------------------

java.io.IOException”类型的未经处理的异常在 PDFBox-0.7.3.dll 中发生
其他信息: Error: Could not find predefined CMAP file for 'UniGB-UTF16-H'

using iTextSharp.text.pdf;
using iTextSharp.text.pdf.parser;
using org.pdfbox.pdmodel;
using org.pdfbox.util;
using System.IO;
private void button1_Click(object sender, EventArgs e)
{

FileInfo file = new FileInfo(@"c:\invoice.pdf");
FileInfo txtfile = new FileInfo(@"c:\invoice.txt");
pdf2txt(file, txtfile);

}

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, System.Text.Encoding.GetEncoding("gb2312"));
swPdfChange.Write(text);
swPdfChange.Close();
}

1个回答

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!