试试这个代码
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using iTextSharp.text.pdf;
using iTextSharp.text.pdf.parser;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
ExtractTextFromPDFPage("c:\sample.pdf", 1);
}
public void ExtractTextFromPDFPage(string pdfFile, int pageNumber)
{
PdfReader reader = new PdfReader(pdfFile);
string text = PdfTextExtractor.GetTextFromPage(reader, pageNumber);
try { reader.Close(); }
catch { }
richTextBox1.Text = text;
}
}
}
从http://en.sourceforge.jp/projects/sfnet_itextsharp/releases/下载 iTextSharp dll
并添加到参考