com.aspose.words

Class MetafileRenderingMode

  • java.lang.Object
    • com.aspose.words.MetafileRenderingMode
public class MetafileRenderingMode 
extends java.lang.Object

Utility class containing constants. Specifies how Aspose.Words should render WMF and EMF metafiles.

Example:

Shows added fallback to bitmap rendering and changing type of warnings about unsupported metafile records.
public void handleBinaryRasterWarnings() throws Exception {
    Document doc = new Document(getMyDir() + "WMF with image.docx");

    MetafileRenderingOptions metafileRenderingOptions = new MetafileRenderingOptions();
    metafileRenderingOptions.setEmulateRasterOperations(false);
    metafileRenderingOptions.setRenderingMode(MetafileRenderingMode.VECTOR_WITH_FALLBACK);

    // If Aspose.Words cannot correctly render some of the metafile records to vector graphics then Aspose.Words renders this metafile to a bitmap
    HandleDocumentWarnings callback = new HandleDocumentWarnings();
    doc.setWarningCallback(callback);

    PdfSaveOptions saveOptions = new PdfSaveOptions();
    saveOptions.setMetafileRenderingOptions(metafileRenderingOptions);

    doc.save(getArtifactsDir() + "PdfSaveOptions.HandleBinaryRasterWarnings.pdf", saveOptions);

    Assert.assertEquals(callback.mWarnings.getCount(), 1);
    Assert.assertTrue(callback.mWarnings.get(0).getDescription().contains("R2_XORPEN"));
}

public static 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 processing. The callback can be set to listen for warnings generated during document
     * load and/or document save.
     */
    public void warning(final WarningInfo info) {
        //For now type of warnings about unsupported metafile records changed from DataLoss/UnexpectedContent to MinorFormattingLoss
        if (info.getWarningType() == WarningType.MINOR_FORMATTING_LOSS) {
            System.out.println("Unsupported operation: " + info.getDescription());
            this.mWarnings.warning(info);
        }
    }

    public WarningInfoCollection mWarnings = new WarningInfoCollection();
}

Field Summary
static final intVECTOR_WITH_FALLBACK = 0
Aspose.Words tries to render a metafile as vector graphics. If Aspose.Words cannot correctly render some of the metafile records to vector graphics then Aspose.Words renders this metafile to a bitmap.
static final intVECTOR = 1
Aspose.Words renders a metafile as vector graphics.
static final intBITMAP = 2
Aspose.Words invokes GDI+ to render a metafile to a bitmap and then saves the bitmap to the output document.
 

    • Field Detail

      • VECTOR_WITH_FALLBACK = 0

        public static final int VECTOR_WITH_FALLBACK
        Aspose.Words tries to render a metafile as vector graphics. If Aspose.Words cannot correctly render some of the metafile records to vector graphics then Aspose.Words renders this metafile to a bitmap.
      • VECTOR = 1

        public static final int VECTOR
        Aspose.Words renders a metafile as vector graphics.
      • BITMAP = 2

        public static final int BITMAP
        Aspose.Words invokes GDI+ to render a metafile to a bitmap and then saves the bitmap to the output document.