public void HandleBinaryRasterWarnings() { //ExStart //ExFor:MetafileRenderingMode.VectorWithFallback //ExFor:IWarningCallback //ExFor:PdfSaveOptions.MetafileRenderingOptions //ExSummary:Shows added fallback to bitmap rendering and changing type of warnings about unsupported metafile records Document doc = new Document(MyDir + "PdfSaveOptions.HandleRasterWarnings.doc"); MetafileRenderingOptions metafileRenderingOptions = new MetafileRenderingOptions { EmulateRasterOperations = false, RenderingMode = MetafileRenderingMode.VectorWithFallback }; //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.WarningCallback = callback; PdfSaveOptions saveOptions = new PdfSaveOptions { MetafileRenderingOptions = metafileRenderingOptions }; doc.Save(MyDir + @"\Artifacts\PdfSaveOptions.HandleRasterWarnings.pdf", saveOptions); Assert.AreEqual(1, callback.mWarnings.Count); Assert.True(callback.mWarnings[0].Description.Contains("R2_XORPEN")); }
//ExStart:PdfRenderWarnings public void PdfRenderWarnings() { Document doc = new Document(MyDir + "WMF with image.docx"); MetafileRenderingOptions metafileRenderingOptions = new MetafileRenderingOptions { EmulateRasterOperations = false, RenderingMode = MetafileRenderingMode.VectorWithFallback }; PdfSaveOptions saveOptions = new PdfSaveOptions { MetafileRenderingOptions = metafileRenderingOptions }; // 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.WarningCallback = callback; doc.Save(ArtifactsDir + "WorkingWithPdfSaveOptions.PdfRenderWarnings.pdf", saveOptions); // While the file saves successfully, rendering warnings that occurred during saving are collected here. foreach (WarningInfo warningInfo in callback.mWarnings) { Console.WriteLine(warningInfo.Description); } }
public void ScaleWmfFontsToMetafileSize() { //ExStart:ScaleWmfFontsToMetafileSize Document doc = new Document(MyDir + "WMF with text.docx"); MetafileRenderingOptions metafileRenderingOptions = new MetafileRenderingOptions { ScaleWmfFontsToMetafileSize = false }; // If Aspose.Words cannot correctly render some of the metafile records to vector graphics // then Aspose.Words renders this metafile to a bitmap. PdfSaveOptions saveOptions = new PdfSaveOptions { MetafileRenderingOptions = metafileRenderingOptions }; doc.Save(ArtifactsDir + "WorkingWithPdfSaveOptions.ScaleWmfFontsToMetafileSize.pdf", saveOptions); //ExEnd:ScaleWmfFontsToMetafileSize }
public static void ScaleWmfFontsToMetafileSize(String dataDir) { // ExStart:ScaleWmfFontsToMetafileSize // The path to the documents directory. Document doc = new Document(dataDir + "MetafileRendering.docx"); MetafileRenderingOptions metafileRenderingOptions = new MetafileRenderingOptions { ScaleWmfFontsToMetafileSize = false }; // If Aspose.Words cannot correctly render some of the metafile records to vector graphics then Aspose.Words renders this metafile to a bitmap. PdfSaveOptions options = new PdfSaveOptions { MetafileRenderingOptions = metafileRenderingOptions }; dataDir = dataDir + "ScaleWmfFontsToMetafileSize_out.pdf"; doc.Save(dataDir, options); // ExEnd:ScaleWmfFontsToMetafileSize Console.WriteLine("\nFonts as metafile are rendered to its default size in PDF. File saved at " + dataDir); }
// ExEnd:PdfRenderWarnings public static void RenderMetafileToBitmap(string dataDir) { // Load the document from disk. Document doc = new Document(dataDir + "PdfRenderWarnings.doc"); MetafileRenderingOptions metafileRenderingOptions = new MetafileRenderingOptions { EmulateRasterOperations = false, RenderingMode = MetafileRenderingMode.VectorWithFallback }; // 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.WarningCallback = callback; PdfSaveOptions saveOptions = new PdfSaveOptions(); saveOptions.MetafileRenderingOptions = metafileRenderingOptions; doc.Save(dataDir + "PdfSaveOptions.HandleRasterWarnings.pdf", saveOptions); }