dll发上来看看
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;using System.Text;
using System.Windows.Forms;
using iTextSharp;
using iTextSharp.text;
using iTextSharp.text.pdf;
using iTextSharp.text.xml;
你调试一下看fn是不是正确的。
private void button1_Click(object sender, EventArgs e)
{
string pdfStr = readPDF(@"C:\WS994482.pdf");
System.IO.File.WriteAllText(@"C:\FromPdf.txt", pdfStr);
}
private string readPDF(string fn)
{
PdfReader p = new PdfReader(fn);
这个问题的原因有两个,一个是PDF本身文件有问题,比如损坏了,另外就是程序写的问题
我也出现了这个问题,因为我的参数是MemoryStream,在创建PdfReader 的时候忘了将Positon设置成0,这样就没有读取到任何数据,更别说读取header 了