Search code examples
c#.netms-wordaspose

Get height of rendered text and images in MS Word


I'm creating a newspaper authoring system. Today I'm using Aspose.Words library to generate newspaper using Docx format as output, based on a lot of other documents as input.

The basic idea is to load a lot of articles documents into a List, then generate a final docx with newspaper.

We need to get the total height of a text (with images and tables) inside columns. As libraries like Aspose.Words deal with Docx format like DOM, there isn't way to know how text will be arranged inside columns. Then I can't know the real height.

We've worked in our own way to get this height. I'm using MeasureString() function from System.Drawing.Graphics namespace. It returns width and height used by string and I can estimate how many lines (and points or inches) it will use inside a column.

But it is very poor and we need a more decent solution. We are thinking to use OpenXML SDK to get this Height, can we?

Aspose.Words doesn't support a way to know it and all Render classes are private to the library.

Can you think a new way to get this height?

Thank you, Daniel Koch


Solution

  • Thank all for answer.

    I finished it changing Aspose.Words to PDFLib. Now I can control pages, columns or anything using Postscript Points.

    We keep Aspose.Words only to content import, but it isn't indicate to print newsletter.