简体   繁体   中英

itextsharp and pdf

i want to read a pdf file line per line but i want to maintain his original format

¿can i do this with itextsharp?

i use the next code :

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

thanks, i really need your help

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#

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM