Aspose.Imaging.Examples.CSharp.ModifyingAndConvertingImages.MetaFiles.ConvertEMFToPDF.Run C# (CSharp) Метод

Run() публичный статический Метод

public static Run ( ) : void
Результат void
        public static void Run()
        {
            // ExStart:ConvertEMFToPDF
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_MetaFiles();

            string[] filePaths = {
                "Picture1.emf"
            };

            foreach (string filePath in filePaths)
            {
                string outPath = dataDir + filePath + "_out.pdf";
                using (var image = (EmfImage)Image.Load(dataDir + filePath))
                using (FileStream outputStream = new FileStream(outPath, FileMode.Create))
                {
                    if (!image.Header.EmfHeader.Valid)
                    {
                        throw new ImageLoadException(string.Format("The file {0} is not valid", outPath));
                    }

                    EmfRasterizationOptions emfRasterization = new EmfRasterizationOptions();
                    emfRasterization.PageWidth = image.Width;
                    emfRasterization.PageHeight = image.Height;
                    emfRasterization.BackgroundColor = Color.WhiteSmoke;
                    PdfOptions pdfOptions = new PdfOptions();
                    pdfOptions.VectorRasterizationOptions = emfRasterization;
                    image.Save(outputStream, pdfOptions);
                }
            }
            // ExEnd:ConvertEMFToPDF
        }
    }
ConvertEMFToPDF