public interface IWarningCallback
Example: Example:
public class HandleDocumentWarnings implements IWarningCallback
{
/**
* Our callback only needs to implement the "Warning" method. This method is called whenever there is a
* potential issue during document procssing. The callback can be set to listen for warnings generated during document
* load and/or document save.
*/
public void warning(WarningInfo info)
{
// We are only interested in fonts being substituted.
if (info.getWarningType() == WarningType.FONT_SUBSTITUTION)
{
System.out.println("Font substitution: " + info.getDescription());
}
}
}
// Load the document to render.
Document doc = new Document(getMyDir() + "Document.doc");
// We can choose the default font to use in the case of any missing fonts.
FontSettings.setDefaultFontName("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.setFontsFolder("", false);
// Create a new class implementing IWarningCallback which collect any warnings produced during document save.
HandleDocumentWarnings callback = new HandleDocumentWarnings();
// We assign the callback to the appropriate save options class. In this case, we are going to save to PDF
// so we create a PdfSaveOptions class and assign the callback there.
PdfSaveOptions saveOptions = new PdfSaveOptions();
saveOptions.setWarningCallback(callback);
// Pass the save options along with the save path to the save method.
doc.save(getMyDir() + "Rendering.MissingFontNotification Out.pdf", saveOptions);
Method Summary | ||
---|---|---|
abstract void | warning(WarningInfo info) | |
Aspose.Words invokes this method when it encounters some issue during document loading or saving that might result in loss of formatting or data fidelity. |
Method Detail |
---|
warning | |
public abstract void warning(WarningInfo info) |