1

我想每行读取一个 pdf 文件行,但我想保持他的原始格式

¿我可以用 itextsharp 做到这一点吗?

我使用下一个代码:

private void button1_Click(object sender, EventArgs e)
        {

            string text = string.Empty;
            string path = string.Empty;
            path = "C:\\Documents and Settings\\Rafael\\Desktop\\Imprimiendo\\Print1.pdf";
            PdfReader reader = new PdfReader(path);

            for (int page = 1; page <= reader.NumberOfPages; page++)
            {
                text = PdfTextExtractor.GetTextFromPage(reader, page);
                richTextBox1.Text = text;

            }
            reader.Close();
            return;
        }

谢谢,我真的需要你的帮助

4

1 回答 1

1

If you want to read PDF file with small data in it, iTextsharp would be the best choice, you may find answer here:

Reading PDF content with itextsharp dll in VB.NET or C#

However, if you have huge data in your PDF file, iTextsharp will have problems in realizing this task. in such a case, you may need a third party library. This article may help you much:

Read PDF file in C#

于 2012-11-28T08:09:22.383 回答