Free Support Forum - aspose.com

Pdf: How do you determine backup font?

Hi,

I recently upgraded from 16.12 to 17.7 and noticed that on one of our test machines the pdf produced is using a different font.

Now this is a Word document where the machine producing the PDF does not have the required font, so it is expected to use a ‘backup’ font.
On 16.12 the font used as ‘backup’ was Arial.
Now, for some reason, it is using a font called Gabriola which is very different from the original font.
It also causes the pdf to have an extra blank page.

Because the machine does not have the required font in the first place, I have no real expectations here.
It would be useful, however, to know how Aspose decided on which ‘backup’ font to use and why this changed between 16.12 and 17.7?

Thank you

@ServerSide527

Thanks for your inquiry. We have improved the font substitution mechanism in Aspose.Words for .NET 17.3. Now Aspose.Words use Font info from document to substitute the missing fonts. Please check Public API and Backward Incompatible changes section in Release notes of Aspose.Words for .NET 17.3.0 and following documentation link for more details of Font substitution details.

Font Availability and Substitution

You may implement IWarningCallback to get notification of missing fonts and install these fonts accordingly.

Document docWord = new Document("Input.docx");
docWord.WarningCallback = new HandleDocumentWarnings();
docWord.Save("AW_177.pdf");


public class HandleDocumentWarnings : IWarningCallback
{
    /// <summary>
    /// Our callback only needs to implement the "Warning" method. This method is called whenever there is a
    /// Potential issue during document processing. The callback can be set to listen for warnings generated during document
    /// Load and/or document save.
    /// </summary>
    public void Warning(WarningInfo info)
    {
        // We are only interested in fonts being substituted.
        if (info.WarningType == WarningType.FontSubstitution)
        {
            Console.WriteLine("Font substitution: " + info.Description);
        }
    }
}