public interface IWarningCallback
Example:
public void handleBinaryRasterWarnings() throws Exception
{
Document doc = new Document(getMyDir() + "WMF with image.docx");
MetafileRenderingOptions metafileRenderingOptions = new MetafileRenderingOptions();
// Set the "EmulateRasterOperations" property to "false" to fall back to bitmap when
// it encounters a metafile, which will require raster operations to render in the output PDF.
metafileRenderingOptions.setEmulateRasterOperations(false);
// Set the "RenderingMode" property to "VectorWithFallback" to try to render every metafile using vector graphics.
metafileRenderingOptions.setRenderingMode(MetafileRenderingMode.VECTOR_WITH_FALLBACK);
// Create a "PdfSaveOptions" object that we can pass to the document's "Save" method
// to modify how that method converts the document to .PDF and applies the configuration
// in our MetafileRenderingOptions object to the saving operation.
PdfSaveOptions saveOptions = new PdfSaveOptions();
saveOptions.setMetafileRenderingOptions(metafileRenderingOptions);
HandleDocumentWarnings callback = new HandleDocumentWarnings();
doc.setWarningCallback(callback);
doc.save(getArtifactsDir() + "PdfSaveOptions.HandleBinaryRasterWarnings.pdf", saveOptions);
Assert.assertEquals(1, callback.mWarnings.getCount());
Assert.assertEquals("'R2_XORPEN' binary raster operation is partly supported.",
callback.mWarnings.get(0).getDescription());
}
/// <summary>
/// Prints and collects formatting loss-related warnings that occur upon saving a document.
/// </summary>
public static class HandleDocumentWarnings implements IWarningCallback
{
public void warning(WarningInfo info)
{
if (info.getWarningType() == WarningType.MINOR_FORMATTING_LOSS)
{
System.out.println("Unsupported operation: " + info.getDescription());
this.mWarnings.warning(info);
}
}
public WarningInfoCollection mWarnings = new WarningInfoCollection();
}
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) |