public void RecieveFontSubstitutionUpdatePageLayout()
{
// Store the font sources currently used so we can restore them later.
FontSourceBase[] origFontSources = FontSettings.DefaultInstance.GetFontsSources();
// Load the document to render.
Document doc = new Document(MyDir + "Document.doc");
// Create a new class implementing IWarningCallback and assign it to the PdfSaveOptions class.
HandleDocumentWarnings callback = new HandleDocumentWarnings();
doc.WarningCallback = callback;
// We can choose the default font to use in the case of any missing fonts.
FontSettings.DefaultInstance.DefaultFontName = "Arial";
// For testing we will set Aspose.Words to look for fonts only in a folder which doesn't exist. Since Aspose.Words won't
// find any fonts in the specified directory, then during rendering the fonts in the document will be subsuited with the default
// font specified under FontSettings.DefaultFontName. We can pick up on this subsuition using our callback.
FontSettings.DefaultInstance.SetFontsFolder(string.Empty, false);
//ExStart
//ExId:FontSubstitutionUpdatePageLayout
//ExSummary:Demonstrates how IWarningCallback will still recieve warning notifcations even if UpdatePageLayout is called before document save.
// When you call UpdatePageLayout the document is rendered in memory. Any warnings that occured during rendering
// are stored until the document save and then sent to the appropriate WarningCallback.
doc.UpdatePageLayout();
// Even though the document was rendered previously, any save warnings are notified to the user during document save.
doc.Save(MyDir + @"\Artifacts\Rendering.FontsNotificationUpdatePageLayout.pdf");
//ExEnd
Assert.Greater(callback.mFontWarnings.Count, 0);
Assert.True(callback.mFontWarnings[0].WarningType == WarningType.FontSubstitution);
Assert.True(callback.mFontWarnings[0].Description.Contains("has not been found"));
// Restore default fonts.
FontSettings.DefaultInstance.SetFontsSources(origFontSources);
}