---
title: "SVG To PDF"
canonical: https://www.graphicsmill.com/samples/Codecs/VectorFormats/SVGToPdf_cs
product: "Graphics Mill"
source: "Codecs/VectorFormats/SVGToPdf.cs"
---

# SVG To PDF

Converts SVG file to PDF format.

## Instruction

Converts an SVG file to PDF format.

## Usings

```csharp
using Aurigma.GraphicsMill.Codecs;
```

## Code Snippet

```csharp
float dpi = 150;

using (var reader = new SvgReader("Seal.svg", dpi, dpi))
using (var writer = new PdfWriter("Seal_out.pdf"))
using (var gr = writer.GetGraphics())
{
    writer.AddPage(reader.Width, reader.Height, dpi, dpi);
    using (var container = reader.GetContent())
    {
        gr.DrawContainer(container, 0, 0);
    }
}
```

## Explanation

The following code:

- Loads an SVG file using a specified DPI setting for scaling.
- Initializes a `PdfWriter` and adds a page with dimensions and DPI matching the SVG.
- Extracts the vector content from the SVG using `GetContent()` and draws it into the PDF graphics context.
- Saves the result as a PDF file.

## Tags

- [Format Conversion](<https://www.graphicsmill.com/samples/tags/format-conversion_md>): Converting images between formats
- [Graphics Container](<https://www.graphicsmill.com/samples/tags/container_md>): Using graphics containers for grouped items
- [PDF](<https://www.graphicsmill.com/samples/tags/pdf_md>): Importing and exporting PDF documents
- [SVG](<https://www.graphicsmill.com/samples/tags/svg_md>): Importing and exporting SVG graphics

## Input

- [Seal.svg](<https://www.graphicsmill.com/samples/Codecs/compiled/Debug/Seal_svg>) (preview)

## Output

- [Seal\_out.pdf](<https://www.graphicsmill.com/samples/Codecs/compiled/Debug/Seal_out_pdf>) (download)
- [Seal\_out.png](<https://www.graphicsmill.com/samples/Codecs/compiled/Debug/Seal_out_png>) (preview)

## Used APIs

- [Aurigma.GraphicsMill.Codecs.PdfWriter](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Codecs_PdfWriter.htm.md>)
- [Aurigma.GraphicsMill.Codecs.PdfWriter.AddPage(Single,Single,Single,Single)](<https://www.graphicsmill.com/docs/gm/M_Aurigma_GraphicsMill_Codecs_PdfWriter_AddPage_4_37f6c741.htm.md>)
- [Aurigma.GraphicsMill.Codecs.PdfWriter.GetGraphics](<https://www.graphicsmill.com/docs/gm/M_Aurigma_GraphicsMill_Codecs_PdfWriter_GetGraphics.htm.md>)
- [Aurigma.GraphicsMill.Codecs.SvgReader](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Codecs_SvgReader.htm.md>)
- [Aurigma.GraphicsMill.Codecs.SvgReader.GetContent](<https://www.graphicsmill.com/docs/gm/M_Aurigma_GraphicsMill_Codecs_SvgReader_GetContent.htm.md>)
- [Aurigma.GraphicsMill.Drawing.Graphics.DrawContainer(GraphicsContainer,Single,Single)](<https://www.graphicsmill.com/docs/gm/M_Aurigma_GraphicsMill_Drawing_Graphics_DrawContainer_3_098aa7ce.htm.md>)
