DocumentBaseWarningCallback Property
Called during various document processing procedures when an issue is detected that might result in data or formatting fidelity loss.

Namespace: Aspose.Words
Assembly: Aspose.Words (in Aspose.Words.dll) Version: 19.9
Syntax
public IWarningCallback WarningCallback { get; set; }

Property Value

Type: IWarningCallback
Remarks
Document may generate warnings at any stage of its existence, so it's important to setup warning callback as early as possible to avoid the warnings loss. E.g. such properties as PageCount actually build the document layout which is used later for rendering, and the layout warnings may be lost if warning callback is specified just for the rendering calls later.
Examples
Shows how to implement the IWarningCallback to be notified of any font substitution during document save.
[C#]

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);
        }
    }

}
Examples
Demonstrates how to receive notifications of font substitutions by using IWarningCallback.
[C#]

// 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.SubstitutionSettings.DefaultFontSubstitution.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 substituted with the default 
// font specified under FontSettings.DefaultFontName. We can pick up on this substitution using our callback.
FontSettings.DefaultInstance.SetFontsFolder(String.Empty, false);

// Pass the save options along with the save path to the save method.
doc.Save(ArtifactsDir + "Rendering.MissingFontNotification.pdf");
See Also