Word to PDF -- font formatting change


I am using Aspose.Word and Aspose.PDF for converting Word documents to PDF on-the-fly.

There is a problem when a "small-caps" format has been used. The font converts to "all-caps" in the PDF, and is also significantly smaller than in the original Word doc. In our clients' documents, a small-caps font style has been used for Heading2, and so considering that display is the only way to distinguish the headings because outline numbering isn't supported (used in original Word doc), Heading2's look much smaller than Heading 3's, and are actually the same size as the body text (just all in caps).

Our client already has a couple of thousand existing Word documents which are to be converted (as well as ongoing creation of new ones), all using this same style.

Is there a way to specify the formatting style of Headings during the conversion?




Thank you for considering Aspose.

I’ve reproduced your situation and I can’t state that Heading 2 + Small Caps looks much smaller than Heading 3. However, difference between the original .doc and resulting .pdf is obvious so I’ve logged this issue. Please check back later.



I’ve checked the formatting in the XML document, and H2’s are coming out 2 point sizes smaller than the body text:

Word XML
Heading 1 12 12
Heading 2 12 8
Heading 3 12 12
Body 10 10


I’m still trying to resolve this issue for the project, and need some ideas on the best way around it.

Our client’s project has very specific requirements regarding their Word documents.

? Word documents need to be converted to PDF on-the-fly.
I’ve already managed to do, but this has introduced some additional problems.

? The TOC of documents will be stored in a database table, for display on pages on their site.
By looping through the headings in the document, using a counter to keep track of which level I’m in, I’ve managed to build a html string that re-builds the section numbers. This is stored in the database table.

? Headings use an outline numbering style, and they are very specific that the numbering needs to be maintained in the PDF document.
This is the part that I’m having problems trying to find a solution. I understand, now, that Aspose.Word doesn’t support outline numbering, so I’ve been trying to manually add the heading numbers, using the same logic as I’ve used to create the html string. This requires editing the existing Word document, and saving it to another location temporarily (so the original Word doc isn’t modified), and then proceeding with creating the pdf file.

But I’ve run into the added complication here that heading styles that use a small caps font are changed to use a size 4 points smaller than the original document. I’ve been trying to access the Heading style with StyleIdentifier, modifying it to be a normal font (ie, SmallCaps = false), set the point size to be the same size as other headings, and all Heading# in the document would be modified accordingly. But I’ve only been able to figure out how to ClearFormatting(), which removes the style altogether from a selected paragraph.

Is it possible to:

1. Modify the attributes of a built in style (eg, Heading2), and have those changes reflected throughout the Word document prior to conversion to pdf?
2. If it’s not possible to modify the style, how can I manually edit the entry, and include customized formatting? eg, I can clear the formatting easily with .ParagraphFormat.ClearFormatting(). And I can access attributes with builder.Font, but how do I apply these attributes to the selected paragraph? I’ve tried builder.Writeln([string of para]), but it doesn’t modify the existing paragraph, nor does it write a new entry to the Word document.

  1. Yes, this is possible. For example, to modify Heading2 font size, do the following:

    doc.Styles[StyleIdentifier.Heading2].Font.Size = 10;

    2. And this is possible, too. Just extract a Paragraph object using one of the node selection methods or, if you use DocumentBuilder, move it to a particular paragraph and obtain the current paragraph using the CurrentParagraph property. Then set the font of all the runs of this paragraph like following:

    NodeList runs = paragraph.SelectNodes("//Run");

    foreach (Run run in runs)
    // Set font properties for each run



We have released Aspose.Word 3.1.7.

  • Improved conversion of small caps text to PDF.
  • http://www.aspose.com/blogs/Roman.Korchagin/