Embedded fonts in Aspose.Words

Hi,
May i find the list of the font type which is automatically embedded into the word document by Aspose ? Is there any other font types that we need to manually embed or specify in the application to ensure that the font is rendered correctly by Aspose ?
Regards,
hadi teo

Hi Hadi,

Thanks for your inquiry.

hadi:
May i find the list of the font type which is automatically embedded into the word document by Aspose ?

Aspose.Words do not embed fonts in Word document automatically. However, Aspose.Words fully preserves fonts in the document during the open/save cycles. Please use the Document.FontInfos property to access the collection of fonts defined in a document. Please read members of FontInfo Class from following link:
https://reference.aspose.com/words/net/aspose.words.fonts/fontinfo/

Document doc = new Document(MyDir + "in.doc");
FontInfoCollection fonts = doc.FontInfos;
int fontIndex = 1;
// The fonts info extracted from this document does not necessarily mean that the fonts themselves are
// used in the document. If a font is present but not used then most likely they were referenced at some time
// and then removed from the Document.
foreach (FontInfo info in fonts)
{
    // Print out some important details about the font.
    Console.WriteLine("Font #{0}", fontIndex);
    Console.WriteLine("Name: {0}", info.Name);
    Console.WriteLine("IsTrueType: {0}", info.IsTrueType);
    fontIndex++;
}

You can use FontInfo.GetEmbeddedFont method to get the embedded fonts from document. This method returns null if the specified font is not embedded.

*hadi:

Is there any other font types that we need to manually embed or specify in the application to ensure that the font is rendered correctly by Aspose ?*

Aspose.Words fully preserves fonts in the document during the open/save cycles. Unfortunately, there is no way to embed fonts into Word documents. However, we had already logged this feature request as WORDSNET-3827 in our issue tracking system. You will be notified via this forum thread once this feature is available.

I have few things to be clarified

"
Aspose.Words do not embed fonts in Word document automatically. However, Aspose.Words fully preserves fonts in the document during the open/save cycles.
"
I have a font requirement which is “SimSun”. This font MUST be included when saving into *.pdf using Aspose.Words. How do i ensure that this font is included and rendered correctly when saving into *.pdf ? Do you mean that the application where it resides should have “SimSun” font installed properly ?

If the host machine where the application resides HAS NOT been installed with “SimSun” font, then how does Aspose words behave ?

Hi,
I have tested your codes below :

Aspose.Words.Fonts.FontInfoCollection fonts = d.FontInfos;
int fontIndex = 1;
// The fonts info extracted from this document does not necessarily mean that the fonts themselves are
// used in the document. If a font is present but not used then most likely they were referenced at some time
// and then removed from the Document.
foreach (Aspose.Words.Fonts.FontInfo info in fonts)
{
    // Print out some important details about the font.
    Console.WriteLine("Font #{0}", fontIndex);
    Console.WriteLine("Name: {0}", info.Name);
    Console.WriteLine("IsTrueType: {0}", info.IsTrueType);
    fontIndex++;
}
// d.Save(tmpDoc, SaveFormat.Doc);
d.Save(pdfWithoutOMR, SaveFormat.Pdf);

The above codes displays WHAT FONTS are required by the Word document. The code is useful to obtain the list of fonts REQUIRED by the word document.
But how do i force to embed a certain font which may NOT be installed in the host server ? I have experimented by removing the ‘simsun’ font in the environment. After this experiment, a certain character is rendered using different font which is not correct. So in order to avoid this, can we know whether we can include a certain font ‘simsun’ into the application itself ?
Please also refer to the attachment.
Regards,
hadi teo

Hi Hadi,

Please accept my apologies for late response.

Thanks for your inquiry. Please note that Aspose.Words requires TrueType fonts when rendering documents to fixed-page formats (PDF, XPS or SWF). Aspose.Words selects the fonts according to the following process:

  1. Aspose.Words tries to find the required font among the fonts embedded in the original document. Some document formats such as DOCX can contain embedded fonts.
  2. Next, Aspose.Words tries to find a font on the file system with an exact font name match.
  3. If Aspose.Words cannot find a font with the exact name match, Aspose.Words attempts to select the most suitable font from all of the available fonts.
  4. Finally, if Aspose.Words cannot find any fonts on the file system, it renders the document using the free Gentium font that is embedded into the Aspose.Words assembly.

Please use the PdfSaveOptions.EmbedFullFonts and PdfSaveOptions.EmbedStandardWindowsFonts properties to embed the fonts in PDF file. I suggest you to read following documentation links for your kind reference.

https://docs.aspose.com/words/net/specify-rendering-options-when-converting-to-pdf/
https://docs.aspose.com/words/net/specify-rendering-options-when-converting-to-pdf/

Hope this answers your query. Please let us know if you have any more queries.

Hi Tahir,
Thanks for your clear explanation.
I am interested in this statement
“Some document formats such as DOCX can contain embedded fonts.”
Since i am using *.doc Template with data retrieval from the database in order to instantiate word document, you mean that if i switch to *.docx template, then i will be able to utilize embedded font feature ?
For your information, i do not need the *.docx result, because i will directly convert it to *.pdf.
Regards,
hadi teo

Hi Hadi,

Thanks for your inquiry.

When Aspose.Words renders a document, it needs to subset and embed TrueType fonts into the resulting document. This is a normal practice during PDF or XPS generation and it ensures the document will appear identical for any viewer.

hadi:
“Some document formats such as DOCX can contain embedded fonts.”

This is related to Font Availability and Substitution. Please read the details from following documentation link.
https://docs.aspose.com/words/net/using-truetype-fonts/

If your computer do not have “SimSun” font and your document (Doc) have “SimSun” embedded font, Aspose.Words tries to find the required font among the fonts embedded in the original document.

Regarding embedding fonts in Doc file, please read the details from here:
https://support.microsoft.com/en-us/topic/how-to-embed-truetype-fonts-in-a-document-in-word-2000-9ecb9612-4c22-4892-e6e5-7850d964ddc0

Hope this answers your query. Please let us know if you have any more query.

The issues you have found earlier (filed as WORDSNET-3827) have been fixed in this .NET update and this Java update.

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