Enum MetafileRenderingMode

Enum MetafileRenderingMode

Namespace: Aspose.Words.Saving
Assembly: Aspose.Words.dll (25.12.0)

Specifies how Aspose.Words should render WMF and EMF metafiles.

public enum MetafileRenderingMode

Fields

Bitmap = 2

Aspose.Words invokes GDI+ to render a metafile to a bitmap and then saves the bitmap to the output document.

Vector = 1

Aspose.Words renders a metafile as vector graphics.

VectorWithFallback = 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.

Examples

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.That(callback.Warnings.Count, Is.EqualTo(1));
                                                                                                                           Assert.That(callback.Warnings[0].Description, Is.EqualTo("'R2_XORPEN' binary raster operation is not supported."));
                                                                                                                       }

                                                                                                                       /// <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();
                                                                                                                       }
 English