Load SVG document with options

GroupDocs.Conversion provides SvgLoadOptions to control how source SVG (Scalable Vector Graphics) files are processed.

The following options are available:

OptionDescription
FormatThe document type is auto-detected during loading, but you can explicitly specify the source format as SVG
MinimumWidthSet minimum width for converting SVG document. Used when converting to raster formats. Default value is 800.
MinimumHeightSet minimum height for converting SVG document. Used when converting to raster formats. Default value is 600.
CropToContentBoundsGets or sets a value indicating whether to crop the SVG bounding box to the content bounds before conversion. Default value is false.

Load SVG file

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);
}

Load SVG with custom dimensions

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);
}

Load SVG with crop to content bounds

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);
}

Convert SVG to page description language format

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);
}

Convert SVG to Word document

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);
}

Convert SVG to HTML

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);
}
Close
Loading

Analyzing your prompt, please hold on...

An error occurred while retrieving the results. Please refresh the page and try again.