You can read all details at: Convert EMF or WMF to SVG Programmatically using C#
Last active
October 19, 2021 03:13
-
-
Save aspose-com-gists/15d7f2f7de393eb87f75096b3d59c190 to your computer and use it in GitHub Desktop.
Convert EMF or WMF to SVG Programmatically using C#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Path to input EMF file | |
string sourcePath = dataDir + @"test.emf"; | |
// Path for output SVG image | |
string destPath = dataDir + @"EMF_out.svg"; | |
// Load input EMF file | |
using (Image image = Image.Load(sourcePath)) | |
{ | |
// Initilaize EmfRasterizationOptions class object | |
EmfRasterizationOptions emfRasterizationOptions = new EmfRasterizationOptions(); | |
emfRasterizationOptions.BackgroundColor = Color.White; | |
emfRasterizationOptions.PageWidth = image.Width; | |
emfRasterizationOptions.PageHeight = image.Height; | |
// Save output SVG image | |
image.Save(destPath, new SvgOptions() { VectorRasterizationOptions = emfRasterizationOptions }); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Path to input WMF file | |
string sourcePath = dataDir + @"TextHintTest.wmf"; | |
// Path to output SVG image | |
string destPath = dataDir + @"WMF_out.svg"; | |
// Load input WMF file | |
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(sourcePath)) | |
{ | |
// Initialize WmfRasterizationOptions instance | |
WmfRasterizationOptions wmfRasterizationOptions = new WmfRasterizationOptions(); | |
wmfRasterizationOptions.BackgroundColor = Aspose.Imaging.Color.White; | |
wmfRasterizationOptions.PageHeight = image.Height; | |
wmfRasterizationOptions.PageWidth = image.Width; | |
// Save output SVG image | |
image.Save(destPath, new SvgOptions() { VectorRasterizationOptions = wmfRasterizationOptions }); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Load input EMF file | |
using (Image image = Image.Load(dataDir + "Test.emf")) | |
{ | |
// Specify EmfRasterizationOptions instance | |
EmfRasterizationOptions emfRasterizationOptions = new EmfRasterizationOptions(); | |
emfRasterizationOptions.BackgroundColor = Color.White; | |
emfRasterizationOptions.PageWidth = image.Width; | |
emfRasterizationOptions.PageHeight = image.Height; | |
// Save output SVG file | |
image.Save(dataDir + "TextAsShapes_out.svg", new SvgOptions | |
{ | |
// Set boolean property to render text as shapes | |
VectorRasterizationOptions = emfRasterizationOptions, | |
TextAsShapes = true | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment