How to Convert MPP to SVG
Scalable Vector Graphics (SVG) is an XML-based vector image format that supports two-dimensional graphics. It is widely used in web and print environments due to its scalability and high resolution.
Aspose.Tasks for .NET provides full support for exporting Microsoft Project (MPP) files to the SVG format. This feature allows developers to render project views such as Gantt charts into standalone vector graphics. These graphics can then be embedded into web applications, reports, or printed without loss of quality.
Saving a Project as SVG
The Project class exposes the Save method which is used to save a project in various formats. The Save method allows you to render project data to SVG format using the SaveFileFormat enumeration type.
To save a project to SVG:
- Load a Microsoft Project file.
- Save the project to SVG using SaveFileFormat.SVG.
The following lines of code show how to achieve this using C#.
1Project project = new Project("New Project.mpp");
2project.Save("SaveProjectAsSVG_out.SVG", SaveFileFormat.SVG);
1Project project = new Project("New Project.mpp");
2SaveOptions options = new SvgOptions();
3options.FitContent = true;
4options.Timescale = Timescale.ThirdsOfMonths;
5project.Save("UseSvgOptions_out.svg", options);
Using SvgOptions to Customize Output
The SvgOptions class allows you to customize how the output SVG is rendered. For example, you can specify which pages to render or change the output timescale.
Key properties include:
- Timescale – Defines the granularity of the timeline.
- PageSize – Specifies the page size to use during export.
- Pages – A list of page numbers to render.
Conclusion
Aspose.Tasks for .NET makes it easy to convert Microsoft Project files into high-quality vector graphics. The SVG format is ideal for scenarios where scalable and embeddable visualizations are required. For more control over the output, use the SvgOptions class to fine-tune rendering behavior.