Obtener texto de PDF C#


using iTextSharp.text.pdf.parser;

using iTextSharp.text.pdf;

 public string GetText()

        {
            string DocumentText = "", DocumentText2 = "";
            PdfReader oReader = new PdfReader("ruta\\guia.pdf");
            //SimpleTextExtractionStrategy its = new SimpleTextExtractionStrategy();
            int pages = oReader.NumberOfPages;
            //DocumentText = PdfTextExtractor.GetTextFromPage(oReader, 1, its);
            for (int i = 1; i <= pages; i++)
            {
                DocumentText = DocumentText + "\n ============PAGE NUMBER " + i + "============= \n";
                DocumentText = DocumentText + PdfTextExtractor.GetTextFromPage(oReader, i);
            }
            DocumentText2 = PdfTextExtractor.GetTextFromPage(oReader, pages);
            oReader.Close();
            return DocumentText;
        }

Comentarios