Last active
July 31, 2025 19:28
-
-
Save aspose-com-gists/13a181f6ab2c24e0fafbab0c0ffd4af3 to your computer and use it in GitHub Desktop.
Convert SVG to EMF
This file contains hidden or 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
using Aspose.Imaging; | |
using Aspose.Imaging.ImageOptions; | |
namespace CSharp.ModifyingAndConvertingImages.CDR | |
{ | |
class CdrToPngExample | |
{ | |
static void Main() | |
{ | |
// The path to the documents directory. | |
string dataDir = "files"; | |
string[] testFiles = new string[] { "Sample.svg" }; | |
License lic = new License(); | |
lic.SetLicense(dataDir+"License.lic"); | |
// Loop through the files array. | |
foreach (string fileName in testFiles) | |
{ | |
string inputFileName = Path.Combine(dataDir, fileName); | |
string outputFileName = Path.Combine(dataDir, fileName + ".emf"); | |
// Load the source SVG file by calling the Image.Load(inputFileName) method. | |
using (Image image = Image.Load(inputFileName)) | |
{ | |
// Set SVG rasterization options with the same page size as the original image. | |
VectorRasterizationOptions vectorRasterizationOptions = new SvgRasterizationOptions { PageSize = image.Size }; | |
// Initialize EMF options and assign the SVG rasterization settings for vector rendering. | |
EmfOptions emfOptions = new EmfOptions | |
{ | |
VectorRasterizationOptions = vectorRasterizationOptions | |
}; | |
// The Save method will save the resultant EMF file on the disk. | |
image.Save( | |
outputFileName, | |
emfOptions | |
); | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment