I have attached a word document and would like to determine the number of tabs that precede the text for a paragraph.
I can already determine the level of indentation (one indentation seems to be 36.0, two seems to be 72.0).
The attached document contains examples of both (I used tabs to ‘indent’ the text and I used indentation to indent it). I wrote code to print left indent and right indent of paragraph format. Any thoughts on how I can determine;
- number of tabs (e.g. ‘This is tabbed once’ would indicate one tab, ‘This is tabbed twice’ would indicate 2 tabs, others are indicate 0 tabs). Is it something in Runs or Run?
iterate over every paragraph in Document…
if (aParagraph != null)
{
ParagraphFormat paragraphFormat = aParagraph.getParagraphFormat();
if (paragraphFormat != null)
{
double leftIndent = paragraphFormat.getLeftIndent();
double rightIndent = paragraphFormat.getRightIndent();
System.out.println("paragraph left indent is " + leftIndent);
System.out.println("paragraph right indent is " + rightIndent);
}
}
produces(the paragraph text is printed subsequently by caller);
…
Paragraph text This is not indented or tabbed
paragraph left indent is 0.0
paragraph right indent is 0.0
EndParagraph
Paragraph text This is indented once
paragraph left indent is 36.0
paragraph right indent is 0.0
EndParagraph
Paragraph text This is indented twice
paragraph left indent is 72.0
paragraph right indent is 0.0
EndParagraph
Paragraph text
paragraph left indent is 0.0
paragraph right indent is 0.0
EndParagraph
Paragraph text This is not indented or tabbed
paragraph left indent is 0.0
paragraph right indent is 0.0
EndParagraph
Paragraph text This is tabbed once
paragraph left indent is 0.0
paragraph right indent is 0.0
EndParagraph
Paragraph text This is tabbed twice.
paragraph left indent is 0.0
paragraph right indent is 0.0
EndParagraph