ImageGear .NET - Updated
User Guide > How to Work with... > PDF > How to... > Convert... > PDF to SVG

ImageGear .NET provides the ability to convert and save any page from a PDF document to a Scalable Vector Graphics (SVG) file. This can be done by using one of the following API calls:

Since SVG format is not a multi-page format, the SaveDocument API called with default options will only convert and save the first page of the provided PDF document.

This topic provides information about the following:

Text Conversion

ImageGear .NET PDF to SVG converter is optimized to provide the best text fidelity results. For that purpose, all PDF text elements are converted to SVG outlining paths, which are not searchable for text.

Color Profiles

ImageGear .NET PDF to SVG color converter applies the default color space defined in the PDF document. If no default color space is defined, all PDF colors defined in CMYK color space are converted to RGB using the Windows ICM and the color profiles enabled in the ImageGear .NET color profile manager. The color profile transformation uses the ICC profile specified in ImGearColorProfileManager.CmykProfile. If this is not set, then the default color profile distributed with ImageGear .NET (ig_cmyk_profile.icm) is used.

Password-Protected PDF Documents

ImageGear .NET PDF to SVG converter requires “Content Copying” permission to the source PDF document to be granted, which means that if a PDF document is secured, it should be opened with the password that allows access to its internals.

If this permission is not granted, the ImageGear .NET PDF to SVG converter will turn on the rasterizaton mode for this document, which will rasterize any PDF page from this document prior to converting to SVG. The resolution of the raster image embedded to SVG will be set using the PDF control parameters.


Most SVG viewers, including Internet Explorer, Chrome, and Firefox browsers, enable edge anti-aliasing, but do not allow turning it off. Although in most cases anti-aliasing makes vector graphics look much better and smoother, there are cases when anti-aliasing leads to unintended SVG rendering effects like the following:

No Thin Line Enhancement in SVG

While the ImageGear .NET PDF renderer provides enhanced rendering of thin lines when a PDF page is zoomed out, ensuring that 1 pixel lines are still visible even when the page is zoomed far out, SVG viewers normally don’t support that. So, thin lines converted from PDF will have the correct widths in SVG, but will be scaled proportionally and may disappear if a page is zoomed out too much.

ConvertPDFtoSVG Sample

The following ConvertPdftoSVG sample method illustrates how you can convert a PDF file to SVG file.

Copy Code
      private void ConvertPdftoSVG(string inputFile, string outputFile)
           ImGearPage imGearPDFPage = null;

           // Open file and load PDF page.
           using (var stream = new FileStream(inputFile, FileMode.Open, FileAccess.Read, FileShare.Read))
                   // Load PDF page.
                   imGearPDFPage = ImGearFileFormats.LoadPage(stream, 0);
               catch (ImGearException ex)
                   MessageBox.Show(string.Format("Could not load file { 0}", ex.Message));

           // Open output file and save to SVG.
           using (var fileStream = new FileStream(outputFile, FileMode.Create, FileAccess.ReadWrite))
               ImGearFileFormats.SavePage(imGearPDFPage, fileStream, 0, ImGearSavingModes.OVERWRITE, ImGearSavingFormats.SVG);
Copy Code
   Private Sub ConvertPdftoSVG(ByVal inputFile As String, ByVal outputFile As String)
       Dim imGearPDFPage As ImGearPage = Nothing

       ' Open file and load PDF page.
       Using stream = New FileStream(inputFile, FileMode.Open, FileAccess.Read, FileShare.Read)
               ' Load PDF page.
               imGearPDFPage = ImGearFileFormats.LoadPage(stream, 0)
           Catch ex As ImGearException
               MessageBox.Show(String.Format("Could not load file { 0}", ex.Message))
           End Try
       End Using

       ' Open output file and save to SVG.
       Using fileStream = New FileStream(outputFile, FileMode.Create, FileAccess.ReadWrite)
           ImGearFileFormats.SavePage(imGearPDFPage, fileStream, 0, ImGearSavingModes.OVERWRITE, ImGearSavingFormats.SVG)
       End Using
   End Sub

Also you can specify a background color for the converted SVG file using PDF control parameters.

Copy Code
           // Get SVGBackgroundColor global control parameter.
           IImGearFormat pdfFormat = ImGearFileFormats.Filters.Get(ImGearFormats.PDF);
           ImGearControlParameter xParam = pdfFormat.Parameters.GetByName("SVGBackgroundColor");
           ImGearRGBQuad rgb = (ImGearRGBQuad)xParam.Value;

           // Select new color.
           var colorDialog = new ColorDialog
               Color = System.Drawing.Color.FromArgb(rgb.Red, rgb.Green, rgb.Blue)

           // Set selected color as new backround value.
           if (colorDialog.ShowDialog() == DialogResult.OK)
               xParam.Value = new ImGearRGBQuad(colorDialog.Color.R, colorDialog.Color.G, colorDialog.Color.B);
Copy Code
       ' Get SVGBackgroundColor global control parameter.
       Dim pdfFormat As IImGearFormat = ImGearFileFormats.Filters.[Get](ImGearFormats.PDF)
       Dim xParam As ImGearControlParameter = pdfFormat.Parameters.GetByName("SVGBackgroundColor")
       Dim rgb As ImGearRGBQuad = DirectCast(xParam.Value, ImGearRGBQuad)

       ' Select new color.
       Dim colorDialog = New ColorDialog() With{.Color = System.Drawing.Color.FromArgb(rgb.Red, rgb.Green, rgb.Blue)}

       ' Set selected color as new backround value.
       If ColorDialog.ShowDialog() = DialogResult.OK Then
           xParam.Value = New ImGearRGBQuad(ColorDialog.Color.R, ColorDialog.Color.G, ColorDialog.Color.B)
       End If