Ejemplo n.º 1
0
        private string[] readPDF(string path)
        {
            using (PdfDocument document = PdfDocument.Open(path))
            {
                string[] ret = new string[document.NumberOfPages];
                for (int page = 1; page < document.NumberOfPages; page++)
                {
                    #region Reading text for Linguistic logic purposes
                    Page   myPage   = document.GetPage(page);
                    string pageText = myPage.Text;
                    pageText = pageText.TrimStart();
                    pageText = pageText.TrimEnd();

                    //layout edits
                    ret = formatOddFileLayout(pageText);
                    #endregion

                    #region Reading Letters for layout purposes
                    //pigLatinPDF = new PdfDocument(document.NumberOfPages);
                    //pigLatinPDF.GetPage(page) readPDFLayout(myPage, document.NumberOfPages);
                    #endregion
                }

                return(ret);
            }
        }
        private string[] readPDF(string path)
        {
            using (PdfDocument document = PdfDocument.Open(path))
            {
                //int myPageCount = document.NumberOfPages;
                int        myPdfTextLenght = 0;
                string[]   ret             = new string[document.NumberOfPages];
                string[][] PDFtext         = new string[document.NumberOfPages][];

                for (int page = 1; page <= document.NumberOfPages; page++)
                {
                    #region Reading text for Linguistic logic purposes
                    Page   myPage   = document.GetPage(page);
                    string pageText = myPage.Text;
                    pageText = pageText.TrimStart();
                    pageText = pageText.TrimEnd();


                    PDFtext[page - 1] = formatOddFileLayout(pageText);
                    myPdfTextLenght   = myPdfTextLenght + PDFtext[page - 1].Length;

                    //layout edits
                    // ret[page-1] = formatOddFileLayout(pageText);
                    #endregion

                    #region Reading Letters for layout purposes
                    //pigLatinPDF = new PdfDocument(document.NumberOfPages);
                    //pigLatinPDF.GetPage(page) readPDFLayout(myPage, document.NumberOfPages);
                    #endregion
                }
                ret = new string[myPdfTextLenght];
                int copyIndex = 0;

                //for (int page = 1; page <= document.NumberOfPages; page++)
                //{
                foreach (var array in PDFtext)
                {
                    array.CopyTo(ret, copyIndex);
                    copyIndex = copyIndex + array.Length - 1;
                }
                //}

                return(ret);
            }
        }