MetafileRenderingMode
Contents
[
Hide
]Inheritance: java.lang.Object
public class MetafileRenderingMode
Specifies how Aspose.Words should render WMF and EMF metafiles.
Examples:
Shows added a 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();
// 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 not supported.",
callback.mWarnings.get(0).getDescription());
}
///
/// Prints and collects formatting loss-related warnings that occur upon saving a document.
///
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();
}
Fields
Field | Description |
---|---|
BITMAP | Aspose.Words invokes GDI+ to render a metafile to a bitmap and then saves the bitmap to the output document. |
VECTOR | Aspose.Words renders a metafile as vector graphics. |
VECTOR_WITH_FALLBACK | Aspose.Words tries to render a metafile as vector graphics. |
length |
Methods
Method | Description |
---|---|
fromName(String metafileRenderingModeName) | |
getName(int metafileRenderingMode) | |
getValues() | |
toString(int metafileRenderingMode) |
BITMAP
public static int BITMAP
Aspose.Words invokes GDI+ to render a metafile to a bitmap and then saves the bitmap to the output document.
VECTOR
public static int VECTOR
Aspose.Words renders a metafile as vector graphics.
VECTOR_WITH_FALLBACK
public static 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.
length
public static int length
fromName(String metafileRenderingModeName)
public static int fromName(String metafileRenderingModeName)
Parameters:
Parameter | Type | Description |
---|---|---|
metafileRenderingModeName | java.lang.String |
Returns: int
getName(int metafileRenderingMode)
public static String getName(int metafileRenderingMode)
Parameters:
Parameter | Type | Description |
---|---|---|
metafileRenderingMode | int |
Returns: java.lang.String
getValues()
public static int[] getValues()
Returns: int[]
toString(int metafileRenderingMode)
public static String toString(int metafileRenderingMode)
Parameters:
Parameter | Type | Description |
---|---|---|
metafileRenderingMode | int |
Returns: java.lang.String