Example #1
0
        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"));
        }
Example #2
0
        //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);
            }
        }
Example #3
0
        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
        }
Example #4
0
        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);
        }
Example #5
0
        // 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);
        }