Load SVG document with options
Leave feedback
On this page
GroupDocs.Conversion provides SvgLoadOptions to control how source SVG (Scalable Vector Graphics) files are processed.
The following options are available:
| Option | Description |
|---|---|
| Format | The document type is auto-detected during loading, but you can explicitly specify the source format as SVG |
| MinimumWidth | Set minimum width for converting SVG document. Used when converting to raster formats. Default value is 800. |
| MinimumHeight | Set minimum height for converting SVG document. Used when converting to raster formats. Default value is 600. |
| CropToContentBounds | Gets or sets a value indicating whether to crop the SVG bounding box to the content bounds before conversion. Default value is false. |
The following code snippet shows how to load an SVG file with explicit format specification:
With v24.10 and later:
using GroupDocs.Conversion;
using GroupDocs.Conversion.FileTypes;
using GroupDocs.Conversion.Options.Convert;
using GroupDocs.Conversion.Options.Load;
Func<LoadContext, LoadOptions> getLoadOptions = loadContext => new SvgLoadOptions
{
Format = PageDescriptionLanguageFileType.Svg
};
using (Converter converter = new Converter("vector-graphic.svg", getLoadOptions))
{
PdfConvertOptions options = new PdfConvertOptions();
converter.Convert("vector-graphic.pdf", options);
}
Before v24.10:
using GroupDocs.Conversion;
using GroupDocs.Conversion.FileTypes;
using GroupDocs.Conversion.Options.Convert;
using GroupDocs.Conversion.Options.Load;
Func<LoadOptions> getLoadOptions = () => new SvgLoadOptions
{
Format = PageDescriptionLanguageFileType.Svg
};
using (Converter converter = new Converter("vector-graphic.svg", getLoadOptions))
{
PdfConvertOptions options = new PdfConvertOptions();
converter.Convert("vector-graphic.pdf", options);
}
The following code snippet shows how to load an SVG file with custom minimum dimensions for raster format conversion:
With v24.10 and later:
using GroupDocs.Conversion;
using GroupDocs.Conversion.FileTypes;
using GroupDocs.Conversion.Options.Convert;
using GroupDocs.Conversion.Options.Load;
Func<LoadContext, LoadOptions> getLoadOptions = loadContext => new SvgLoadOptions
{
Format = PageDescriptionLanguageFileType.Svg,
MinimumWidth = 1200,
MinimumHeight = 900
};
using (Converter converter = new Converter("logo.svg", getLoadOptions))
{
ImageConvertOptions options = new ImageConvertOptions
{
Format = ImageFileType.Png
};
converter.Convert("logo.png", options);
}
Before v24.10:
using GroupDocs.Conversion;
using GroupDocs.Conversion.FileTypes;
using GroupDocs.Conversion.Options.Convert;
using GroupDocs.Conversion.Options.Load;
Func<LoadOptions> getLoadOptions = () => new SvgLoadOptions
{
Format = PageDescriptionLanguageFileType.Svg,
MinimumWidth = 1200,
MinimumHeight = 900
};
using (Converter converter = new Converter("logo.svg", getLoadOptions))
{
ImageConvertOptions options = new ImageConvertOptions
{
Format = ImageFileType.Png
};
converter.Convert("logo.png", options);
}
The following code snippet shows how to load an SVG file with cropping to content bounds:
With v24.10 and later:
using GroupDocs.Conversion;
using GroupDocs.Conversion.FileTypes;
using GroupDocs.Conversion.Options.Convert;
using GroupDocs.Conversion.Options.Load;
Func<LoadContext, LoadOptions> getLoadOptions = loadContext => new SvgLoadOptions
{
Format = PageDescriptionLanguageFileType.Svg,
CropToContentBounds = true
};
using (Converter converter = new Converter("icon.svg", getLoadOptions))
{
PdfConvertOptions options = new PdfConvertOptions();
converter.Convert("icon.pdf", options);
}
Before v24.10:
using GroupDocs.Conversion;
using GroupDocs.Conversion.FileTypes;
using GroupDocs.Conversion.Options.Convert;
using GroupDocs.Conversion.Options.Load;
Func<LoadOptions> getLoadOptions = () => new SvgLoadOptions
{
Format = PageDescriptionLanguageFileType.Svg,
CropToContentBounds = true
};
using (Converter converter = new Converter("icon.svg", getLoadOptions))
{
PdfConvertOptions options = new PdfConvertOptions();
converter.Convert("icon.pdf", options);
}
The following code snippet shows how to load an SVG file and convert it to XPS format:
With v24.10 and later:
using GroupDocs.Conversion;
using GroupDocs.Conversion.FileTypes;
using GroupDocs.Conversion.Options.Convert;
using GroupDocs.Conversion.Options.Load;
Func<LoadContext, LoadOptions> getLoadOptions = loadContext => new SvgLoadOptions
{
Format = PageDescriptionLanguageFileType.Svg
};
using (Converter converter = new Converter("diagram.svg", getLoadOptions))
{
PageDescriptionLanguageConvertOptions options = new PageDescriptionLanguageConvertOptions
{
Format = PageDescriptionLanguageFileType.Xps
};
converter.Convert("diagram.xps", options);
}
Before v24.10:
using GroupDocs.Conversion;
using GroupDocs.Conversion.FileTypes;
using GroupDocs.Conversion.Options.Convert;
using GroupDocs.Conversion.Options.Load;
Func<LoadOptions> getLoadOptions = () => new SvgLoadOptions
{
Format = PageDescriptionLanguageFileType.Svg
};
using (Converter converter = new Converter("diagram.svg", getLoadOptions))
{
PageDescriptionLanguageConvertOptions options = new PageDescriptionLanguageConvertOptions
{
Format = PageDescriptionLanguageFileType.Xps
};
converter.Convert("diagram.xps", options);
}
The following code snippet shows how to load an SVG file and convert it to a Word document:
With v24.10 and later:
using GroupDocs.Conversion;
using GroupDocs.Conversion.FileTypes;
using GroupDocs.Conversion.Options.Convert;
using GroupDocs.Conversion.Options.Load;
Func<LoadContext, LoadOptions> getLoadOptions = loadContext => new SvgLoadOptions
{
Format = PageDescriptionLanguageFileType.Svg
};
using (Converter converter = new Converter("infographic.svg", getLoadOptions))
{
WordProcessingConvertOptions options = new WordProcessingConvertOptions();
converter.Convert("infographic.docx", options);
}
Before v24.10:
using GroupDocs.Conversion;
using GroupDocs.Conversion.FileTypes;
using GroupDocs.Conversion.Options.Convert;
using GroupDocs.Conversion.Options.Load;
Func<LoadOptions> getLoadOptions = () => new SvgLoadOptions
{
Format = PageDescriptionLanguageFileType.Svg
};
using (Converter converter = new Converter("infographic.svg", getLoadOptions))
{
WordProcessingConvertOptions options = new WordProcessingConvertOptions();
converter.Convert("infographic.docx", options);
}
The following code snippet shows how to load an SVG file and convert it to HTML:
With v24.10 and later:
using GroupDocs.Conversion;
using GroupDocs.Conversion.FileTypes;
using GroupDocs.Conversion.Options.Convert;
using GroupDocs.Conversion.Options.Load;
Func<LoadContext, LoadOptions> getLoadOptions = loadContext => new SvgLoadOptions
{
Format = PageDescriptionLanguageFileType.Svg
};
using (Converter converter = new Converter("chart.svg", getLoadOptions))
{
WebConvertOptions options = new WebConvertOptions();
converter.Convert("chart.html", options);
}
Before v24.10:
using GroupDocs.Conversion;
using GroupDocs.Conversion.FileTypes;
using GroupDocs.Conversion.Options.Convert;
using GroupDocs.Conversion.Options.Load;
Func<LoadOptions> getLoadOptions = () => new SvgLoadOptions
{
Format = PageDescriptionLanguageFileType.Svg
};
using (Converter converter = new Converter("chart.svg", getLoadOptions))
{
WebConvertOptions options = new WebConvertOptions();
converter.Convert("chart.html", options);
}
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.