We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Not getting correct font information when saving to PDF

I have scoured the API documentation and forums for an answer to what
should seemingly be a simple question, but I can’t find what I need.

We have various Word documents created by users containing merge fields
from which we create individual documents, then convert them to PDF.
The body text of one of the word documents uses the TrueType Calibri
font (commonly used by Word 2007). When converted to PDF, the body text
shows up in Times New Roman. When I saved off the intermediate PDF XML
file, I see that the FontName attributes of the Segment elements are
all set to “Times New Roman”.

So, how do convert t PDF in a way that will allow the font information
to be preserved? I see various articles in the documentation for
dealing with fonts once you have an Aspose.Pdf.Pdf object, but by then
I’ve already lost the font information.

I am attaching minimal versions of the original .docx file, the resulting PDF .xml file, and the code used to generate the PDF.

Thanks in advance,

Eric

Hi Eric,

Thanks for your request. Font is changed from Calibri to Times New roman because Aspose.Words does not support Word 2007 Themes. This problem is logged in our defect database as issue #5313. I will notify you as soon as it is fixed.
Best regards.

Hi Alexey, hi Eric!
I think that I got a related problem:
When I create a Document instance out of an existing Word file to manipulate it, the Calibri font is changed to Times New Roman by saving the Document (not to pdf but to docx).
But when creating an in-memory Document without having a physical Word base file and adding text runs which have the Calibri font and then saving the document, the Calibri font seems to remain in the saved docx file as it should.
This is strange because you said that Aspose does not support Word 2007 themes like Calibri, isn’t it?
The docx file I’m manipulating and saving with Aspose is originally created by Word 2003. Could this be the problem?
Is there a workaround to keep the Calibri-Style in the document?
I tried thinks like saving the base document and loading it again (both in doc and docx format) before manipulating it in oder to get a proper docx format. This did not work.
Thanks a lot for your help,
cheers,
Stephan

Hi Stephan,

Thanks for your inquiry. Calibri is just a font, it is not a Theme. In Ms Word you can set font of some text using different approaches – you can change font in style applied to some text; you can select some text and set font (in this case font of particular run of text will be changed); and in MS Word 2007 you can use Themes to set the font. When font is specified via theme, MS Word shows “+” sign at the beginning of theme name (see attached screenshot). If font is set using Themes, Aspose.Words just change it to default font (Times New Roman in our case).
Best regards.

Alexey,

Thank you for your quick reply. Is there a workaround that I can give to users before the issue is fixed? Is it simply to set the font on each text element separately, or is there a more clever way around the problem?

Thanks,

Eric

Hi Eric,

As a workaround, you can try to set font using styles. If this will not help, you should set font for each text element separately.
Best regards.

Would there be a practical way to programmatically convert the theme information into style information before rendering to PDF?

Thanks,

Eric

Hi Eric,

Thanks for your inquiry. Unfortunately, there is no way to works with Themes programmatically using Aspose.Words. Because Aspose.Words does not support Themes, as I already mentioned earlier.
Best regards.

Hi Alexey!
Thanks a lot for your quick and good help! That’s exactly my problem: the font is set by the “body”-theme.
If I got you right, I have currently no chance to find out which font is set at a text run of an existing document (with unknown font) if it is set by a theme (just in order to re-set the font again using styles or something else)?
If this should be possible nevertheless, do the concerned text’s formattings get lost?
Is it possible to say when this issue probably will be fixed (version?)?
Thanks again,
cheers,
Stephan

Hi Stephan,

Thanks for your inquiry. Unfortunately, I cannot give you any reliable estimate regarding this issue at the moment. Hopefully, the issue will be resolved in 1-2 month. I will notify you as soon as it is fixed.
Best regards.

The issues you have found earlier (filed as 5313) have been fixed in this update.

This message was posted using Notification2Forum from Downloads module by aspose.notifier.
(30)