How to read a PDF file line by line in c#?

This offers you a tip exactly how PDF is actually structured, as well as after that you may reevaluate what you really want to achieve. (an easy tip: PDF is CERTAINLY NOT a text layout!).

You will certainly need to have a reference to the iTextSharp lib. words range consists of lines of pdf file

for (int i = 1; i <= intPageNum; i++)
        text = PdfTextExtractor.GetTextFromPage(reader, i, new LocationTextExtractionStrategy());

        words = text.Split('\n');
        for (int j = 0, len = words.Length; j < len; j++)
            line = Encoding.UTF8.GetString(Encoding.UTF8.GetBytes(words[j]));

In my windows 8 application, I wish to read through a PDF line by line after that I will just like to designate a String collection. Just how can I do it?

Just how do I launch a PDF Programmatically coming from a C# application in it is actually very own process?

Originally: I would like to open PDF report when i click on switch in C#. Net?

do you need to have to open it for reading through? modifying? image removal? PDFToolkit is what I ordinarily use however stuff, dunno if you can utilize it in c#

What perform you suggest for “open PDF data”? If you require to read through all byties a lot more basic technique is actually:

byte[] byteArray = System.IO.File.ReadAllBytes(@"c:\file.pdf");

to provide the third possible solution to your inquiry:

PdfReader reader = new PdfReader((await file.OpenReadAsync()).AsStream());

            for (int page = 1; page <= reader.NumberOfPages; page++)

                addd.Append(PdfTextExtractor.GetTextFromPage(reader, page));
                string tmp= PdfTextExtractor.GetTextFromPage(reader, page);

                array[page] = tmp.ToString();


, if you desire to modify the PDF-file you can utilize a public library like iTextSharp or even PDFSharp

Leave a Reply

Close Menu