Ahmed Saadawi
Ahmed Saadawi

Reputation: 1

how to get paragraph start and end positions into word file in points on page width - Web Application in C#

I need to get paragraph start and end positions into word file in points on page width points - Web Application C# I got the page width and paragraphs by using Gembox library but I cannot get the start and end points of the paragraph to specify the start/end locations from page line

Upvotes: 0

Views: 86

Answers (1)

Mario Z
Mario Z

Reputation: 4381

In short, that's impossible just by using the given content model (the DocumentModel object).

You see Word documents themselves do not have a page concept, they are of a flow document type, the page concept is specific to a Word application(s) that is rendering it.

To explain this differently, you can think of this the same as how in an HTML file you would have something like this:

<!DOCTYPE html>
<html>
<body>
<h1>My Heading</h1>
<p>My paragraph.</p>
</body>
</html>

And now with that HTML itself, you don't know the coordinates of that <p> element. You would need to use some rendering engine to calculate that (like the ones in Chrome or Firefox).

But note that different rendering engines can calculate things differently, so depending on what rendering engine you use the coordinates could be slightly different.

So, what you need to do is render that content and GemBox.Document provides few options for that.

For example, you could save the DocumentModel to PDF and then read the coordinates of the text elements in that PDF using GemBox.Pdf. To see how you can retrieve the coordinates, check this example: Reading additional information about a text

Upvotes: 0

Related Questions