---
title: "PDF To SVG"
canonical: https://www.graphicsmill.com/samples/Codecs/VectorFormats/PdfToSVG_cs
product: "Graphics Mill"
source: "Codecs/VectorFormats/PdfToSVG.cs"
---

# PDF To SVG

Reads vector content from a PDF file and saves it to an SVG format.

## Instruction

Convert a PDF file to an SVG format by rendering its graphics container content.

## Usings

```csharp
using Aurigma.GraphicsMill.Codecs;
```

## Code Snippet

```csharp
using (var reader = new PdfReader("Seal.pdf"))
using (var writer = new SvgWriter("Seal.svg", reader.Width, reader.Height, reader.DpiX, reader.DpiY))
using (var gr = writer.GetGraphics())
{
    using (var container = reader.Frames[0].GetContent())
    {
        gr.DrawContainer(container, 0, 0);
    }
}
```

## Explanation

The following code:

- Reads a PDF file using `PdfReader`.
- Creates an `SvgWriter` with the same dimensions and resolution as the input PDF.
- Retrieves the graphics container of the first frame from the PDF.
- Draws the container onto the SVG graphics context, resulting in a vector-based output.

## 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.pdf](<https://www.graphicsmill.com/samples/Codecs/compiled/Debug/Seal_pdf>) (download)

## Output

- [Seal.svg](<https://www.graphicsmill.com/samples/Codecs/compiled/Debug/Seal_svg>) (preview)

## Used APIs

- [Aurigma.GraphicsMill.Codecs.ImageReader.DpiX](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_Codecs_ImageReader_DpiX.htm.md>)
- [Aurigma.GraphicsMill.Codecs.ImageReader.DpiY](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_Codecs_ImageReader_DpiY.htm.md>)
- [Aurigma.GraphicsMill.Codecs.PdfFrame.GetContent](<https://www.graphicsmill.com/docs/gm/M_Aurigma_GraphicsMill_Codecs_PdfFrame_GetContent.htm.md>)
- [Aurigma.GraphicsMill.Codecs.PdfReader](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Codecs_PdfReader.htm.md>)
- [Aurigma.GraphicsMill.Codecs.PdfReader.Frames](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_Codecs_PdfReader_Frames.htm.md>)
- [Aurigma.GraphicsMill.Codecs.SvgWriter](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Codecs_SvgWriter.htm.md>)
- [Aurigma.GraphicsMill.Codecs.SvgWriter.GetGraphics](<https://www.graphicsmill.com/docs/gm/M_Aurigma_GraphicsMill_Codecs_SvgWriter_GetGraphics.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>)
