How to get coordinates of Run or other WordProcessing element via OpenXML?

天涯浪子 提交于 2020-01-22 02:14:47

问题


I was wondering if it is possible to find the coordinates of a specific Run (text, no drawing or other elements that have offset parameter) on a page in a Word document using OpenXML SDK. I know that OpenXML is basically .. well XML, and simple runs have no relative, numerical position embedded in them.

I was reading through OpenXML SDK API and found no clues but maybe I have missed something. By coordinates I mean any tuple that can be mapped to pixels if I would generated an image out of the page (imagine you made a screenshot of page)

I suspect, if this is possible, it is not trivial.

Appreciate your help!


回答1:


The Open XML SDK does not include this functionality. This would require a layout engine, which is not part of the SDK.




回答2:


Word is not a page layout program, it's a word processor. Therefore:

No, it's not possible because...

The Word application dynamically lays out a page when it's opened in the Word application. Exactly how it's layed out and where things appear on-screen (or on the printed page) depends on how Word calculates font size as well as line, character and paragraph spacing (in all directions) for the currently selected printer driver. So it can vary and thus cannot be saved in the Open XML file.



来源:https://stackoverflow.com/questions/59665401/how-to-get-coordinates-of-run-or-other-wordprocessing-element-via-openxml

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!