MetafileRenderingOptions Class

Allows to specify additional metafile rendering options.

ExpandedInheritance Hierarchy

SystemObject
  Aspose.Words.SavingMetafileRenderingOptions

Namespace:  Aspose.Words.Saving
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 21.5.0

ExpandedSyntax

public class MetafileRenderingOptions

The MetafileRenderingOptions type exposes the following members.

ExpandedConstructors

  NameDescription
Public methodMetafileRenderingOptions
Initializes a new instance of the MetafileRenderingOptions class

ExpandedProperties

  NameDescription
Public propertyCode exampleEmfPlusDualRenderingMode
Gets or sets a value determining how EMF+ Dual metafiles should be rendered.
Public propertyCode exampleEmulateRasterOperations
Gets or sets a value determining whether or not the raster operations should be emulated.
Public propertyCode exampleRenderingMode
Gets or sets a value determining how metafile images should be rendered.
Public propertyCode exampleScaleWmfFontsToMetafileSize
Gets or sets a value determining whether or not to scale fonts in WMF metafile according to metafile size on the page.
Public propertyCode exampleUseEmfEmbeddedToWmf
Gets or sets a value determining how WMF metafiles with embedded EMF metafiles should be rendered.

ExpandedMethods

  NameDescription
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)

ExpandedExamples

Shows added a fallback to bitmap rendering and changing type of warnings about unsupported metafile records.
public void HandleBinaryRasterWarnings()
{
    Document doc = new Document(MyDir + "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.EmulateRasterOperations = false;

    // Set the "RenderingMode" property to "VectorWithFallback" to try to render every metafile using vector graphics.
    metafileRenderingOptions.RenderingMode = MetafileRenderingMode.VectorWithFallback;

    // 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.MetafileRenderingOptions = metafileRenderingOptions;

    HandleDocumentWarnings callback = new HandleDocumentWarnings();
    doc.WarningCallback = callback;

    doc.Save(ArtifactsDir + "PdfSaveOptions.HandleBinaryRasterWarnings.pdf", saveOptions);

    Assert.AreEqual(1, callback.Warnings.Count);
    Assert.AreEqual("'R2_XORPEN' binary raster operation is partly supported.",
        callback.Warnings[0].Description);
}

/// <summary>
/// Prints and collects formatting loss-related warnings that occur upon saving a document.
/// </summary>
public class HandleDocumentWarnings : IWarningCallback
{
    public void Warning(WarningInfo info)
    {
        if (info.WarningType == WarningType.MinorFormattingLoss)
        {
            Console.WriteLine("Unsupported operation: " + info.Description);
            Warnings.Warning(info);
        }
    }

    public WarningInfoCollection Warnings = new WarningInfoCollection();
}

ExpandedSee Also