1

I have a docx document which consists of some paragraphs and I have to get coordinates (x, y) of this elements from left top corner of document.
I find something like this:

try (InputStream is = new FileInputStream(path)) {
    XWPFDocument doc = new XWPFDocument(is);
    final List<IBodyElement> bodyElements = doc.getBodyElements();
    int x = bodyElements.get(0).getX();    // How can I get something like this?
}

How can I get this information? I couldn't find it in web.
Thanks for help!

John
  • 1,375
  • 4
  • 17
  • 40
  • You can't because this is not the way word processing works. In word processing the document body elements do not have fixed positions. Instead a word processing document body consists of an endless stream of body elements. Their positions result on multiple different factors as content flow, alignment settings, indentation settings, ... – Axel Richter Aug 27 '19 at 08:59
  • @AxelRichter maybe I can compute position of each element in the docx? – John Aug 27 '19 at 09:20
  • Maybe. Good luck! Or are you asking me how to do that? Then my answer is no, it will not be possible. At least it will not be possible to post that big amount of needed code then in an answer here. – Axel Richter Aug 27 '19 at 09:44

0 Answers0