public static string GetInformationAboutCurrentPage(DocumentLayout currentDocumentLayout, LayoutPage currentPage, DocumentPosition currentPosition) { string returnedInformation = ""; int currentPageIndex = currentDocumentLayout.GetPageIndex(currentPage); int totalPageCount = currentDocumentLayout.GetFormattedPageCount(); // get information about page content using a LayoutVisitor descendant CustomDocumentLayoutVisitor visitor = new CustomDocumentLayoutVisitor(); visitor.Visit(currentPage); // get information about page bounds using PageArea properties PageAreaProperties pageAreaProperties = CaculatePageAreaProperties(currentPage.PageAreas[0], currentPosition); returnedInformation += String.Format("\r\nPage: {0} of {1}\r\n", currentPageIndex + 1, totalPageCount); returnedInformation += String.Format("Current page range: {0} - {1}\r\n", currentPage.MainContentRange.Start, currentPage.MainContentRange.Start + currentPage.MainContentRange.Length - 1); returnedInformation += String.Format("Images count: {0}\r\n", visitor.ImagesCount); returnedInformation += String.Format("Tables count: {0}\r\n", visitor.TablesCount); returnedInformation += String.Format("Text Boxes count: {0}\r\n", visitor.TextBoxesCount); returnedInformation += String.Format("Paragraphs count: {0}\r\n", visitor.ParagraphsCount); returnedInformation += String.Format("Text lines count: {0}\r\n", visitor.TextLinesCount); returnedInformation += String.Format("Words (text blocks) count: {0}\r\n", visitor.WordsCount); returnedInformation += String.Format("\r\nColumn: {0} of {1}\r\n", pageAreaProperties.currentColumnIndex, pageAreaProperties.columnCount); returnedInformation += String.Format("Current COLUMN content bounds: {0}\r\n", pageAreaProperties.currentColumnBounds); returnedInformation += String.Format("Current PAGE content bounds: {0}\r\n", pageAreaProperties.currentPageBounds); return(returnedInformation); }
public static string GetInformationAboutCurrentTextBoxContent(LayoutTextBox currentTextBox, DocumentLayout currentLayout) { string returnedInformation = ""; CustomDocumentLayoutVisitor visitor = new CustomDocumentLayoutVisitor(); visitor.Visit(currentTextBox); SubDocument doc = currentLayout.BeginUpdateDocument(currentTextBox); string plainTextContent = doc.GetText(doc.Range); currentLayout.EndUpdateDocument(doc); returnedInformation += String.Format("Lines count: {0}\r\n", visitor.TextLinesCount); returnedInformation += String.Format("Words count: {0}\r\n", visitor.WordsCount); returnedInformation += String.Format("Plain text: {0}\r\n", plainTextContent); return(returnedInformation); }