首页 新闻 会员 周边

PDFBOX 读取数据报错

0
悬赏园豆:10 [已关闭问题] 关闭于 2017-04-25 10:26

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();
}

 

低调又不猥琐的提莫的主页 低调又不猥琐的提莫 | 初学一级 | 园豆:8
提问于:2016-08-25 16:42
< >
分享
所有回答(1)
0

版本低了,我用的1.7.1版本后,这个问题解决了

溜达猫 | 园豆:7 (初学一级) | 2017-06-23 09:30
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册