com.aspose.words
Class WarningType

java.lang.Object
    extended by com.aspose.words.WarningType

public class WarningType 
extends java.lang.Object

Utility class containing constants. Specifies the type of a warning that is issued by Aspose.Words during document loading or saving.

Example:

Shows how to set the property for finding the closest match font among the available font sources instead missing font.
@Test
public void enableFontSubstitution() throws Exception {
    Document doc = new Document(getMyDir() + "Missing font.docx");

    // Assign a custom warning callback
    HandleDocumentSubstitutionWarnings substitutionWarningHandler = new HandleDocumentSubstitutionWarnings();
    doc.setWarningCallback(substitutionWarningHandler);

    // Set a default font name and enable font substitution
    FontSettings fontSettings = new FontSettings();
    fontSettings.getSubstitutionSettings().getDefaultFontSubstitution().setDefaultFontName("Arial");
    fontSettings.getSubstitutionSettings().getFontInfoSubstitution().setEnabled(true);

    // When saving the document with the missing font, we should get a warning
    doc.setFontSettings(fontSettings);
    doc.save(getArtifactsDir() + "Font.EnableFontSubstitution.pdf");

    // List all warnings using an enumerator
    Iterator<WarningInfo> warnings = substitutionWarningHandler.FontWarnings.iterator();
    try /*JAVA: was using*/ {
        while (warnings.hasNext())
            System.out.println(warnings.next().getDescription());
    } finally {
        if (warnings != null) warnings.remove();
    }

    // Warnings are stored in this format
    Assert.assertEquals(WarningSource.LAYOUT, substitutionWarningHandler.FontWarnings.get(0).getSource());
    Assert.assertEquals("Font '28 Days Later' has not been found. Using 'Calibri' font instead. Reason: alternative name from document.",
            substitutionWarningHandler.FontWarnings.get(0).getDescription());

    // The warning info collection can also be cleared like this
    substitutionWarningHandler.FontWarnings.clear();

    Assert.assertNull(substitutionWarningHandler.FontWarnings);
}

public static class HandleDocumentSubstitutionWarnings implements 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.getWarningType() == WarningType.FONT_SUBSTITUTION)
            FontWarnings.warning(info);
    }

    public WarningInfoCollection FontWarnings = new WarningInfoCollection();
}

Field Summary
static final intDATA_LOSS_CATEGORY = 255
           Some text/char/image or other data will be missing from either the document tree following load, or from the created document following save.
static final intDATA_LOSS = 1
           Generic data loss, no specific code.
static final intMAJOR_FORMATTING_LOSS_CATEGORY = 65280
           The resulting document or a particular location in it might look substantially different compared to the original document.
static final intMAJOR_FORMATTING_LOSS = 256
           Generic major formatting loss, no specific code.
static final intMINOR_FORMATTING_LOSS_CATEGORY = 16711680
           The resulting document or a particular location in it might look somewhat different compared to the original document.
static final intMINOR_FORMATTING_LOSS = 65536
           Generic minor formatting loss, no specific code.
static final intFONT_SUBSTITUTION = 131072
           Font has been substituted.
static final intFONT_EMBEDDING = 262144
           Loss of embedded font information during document saving.
static final intUNEXPECTED_CONTENT_CATEGORY = 251658240
           Some content in the source document could not be recognized (i.e. is unsupported), this may or may not cause issues or result in data/formatting loss.
static final intUNEXPECTED_CONTENT = 16777216
           Generic unexpected content, no specific code.
static final intHINT = 268435456
           Advises of a potential problem or suggests an improvement.
 

Field Detail

DATA_LOSS_CATEGORY = 255

public static final int DATA_LOSS_CATEGORY
Some text/char/image or other data will be missing from either the document tree following load, or from the created document following save.

DATA_LOSS = 1

public static final int DATA_LOSS
Generic data loss, no specific code.

MAJOR_FORMATTING_LOSS_CATEGORY = 65280

public static final int MAJOR_FORMATTING_LOSS_CATEGORY
The resulting document or a particular location in it might look substantially different compared to the original document.

MAJOR_FORMATTING_LOSS = 256

public static final int MAJOR_FORMATTING_LOSS
Generic major formatting loss, no specific code.

MINOR_FORMATTING_LOSS_CATEGORY = 16711680

public static final int MINOR_FORMATTING_LOSS_CATEGORY
The resulting document or a particular location in it might look somewhat different compared to the original document.

MINOR_FORMATTING_LOSS = 65536

public static final int MINOR_FORMATTING_LOSS
Generic minor formatting loss, no specific code.

FONT_SUBSTITUTION = 131072

public static final int FONT_SUBSTITUTION
Font has been substituted.

FONT_EMBEDDING = 262144

public static final int FONT_EMBEDDING
Loss of embedded font information during document saving.

UNEXPECTED_CONTENT_CATEGORY = 251658240

public static final int UNEXPECTED_CONTENT_CATEGORY
Some content in the source document could not be recognized (i.e. is unsupported), this may or may not cause issues or result in data/formatting loss.

UNEXPECTED_CONTENT = 16777216

public static final int UNEXPECTED_CONTENT
Generic unexpected content, no specific code.

HINT = 268435456

public static final int HINT
Advises of a potential problem or suggests an improvement.

See Also:
          Aspose.Words Documentation - the home page for the Aspose.Words Product Documentation.
          Aspose.Words Support Forum - our preferred method of support.