ww5552456614
挥剑问情
采纳率28.6%
2016-08-25 09:07 阅读 1.9k

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条回答 默认 最新

相关推荐