从网上找到的 方案---------谨记
需要 下载 PDFBox 包。在这个包中,有一个bin目录。为了读取PDF文件,需要下面的文件:
IKVM.GNU.Classpath.dll
PDFBox-0.7.3.dll
FontBox-0.1.0-dev.dll
IKVM.Runtime.dll
您必须在项目中引用前两个动态库,还要把后两个复制到项目的bin目录中。 示例代码如下(假定使用控制台程序
using System;
using org.pdfbox.pdmodel;
using org.pdfbox.util;
namespace PDFReader
{
class Program
{
static void Main(string[] args)
{
PDDocument doc = PDDocument.load("lopreacamasa.pdf");
PDFTextStripper pdfStripper = new PDFTextStripper();
Console.Write(pdfStripper.getText(doc));
}
}