Letmetestthat
Letmetestthat

Reputation: 1

How can I check the amount of space in a Word header?

I'm currently working on a desktop automation project using the Office applications. I need to check that the header content is correct during the test. A key factor that needs to be right is the position of the header. Is there a way of checking the space within the header, or even the co-ordinates on the page? Something along those lines.

I've looked at the Office Open XML docs but couldn't see anything to do with spacing/position. Any ideas?

Upvotes: 0

Views: 23

Answers (1)

YAS_Bangamuwage
YAS_Bangamuwage

Reputation: 194

How to do it using java: First you need to read xml header content via java and assign it into variable.

<header>  headerNameWithSpaces </header>

String headerValue = "  headerNameWithSpaces";

then use java 8 features to count the spaces.

long spaceCount = headerValue.chars().filter(Character::isWhitespace).count();

Upvotes: 1

Related Questions