# SVG FormSource

| Minimum Version | Q3 2024 |
| --------------- | ------- |

RadPdfProcessing supports SVG FormSource (vector graphics image format). The static `FormSource.FromSvg` method allows you to insert a vector image in the PDF document. The following overloads are available:

| Method                               | Description                                                              |
| ------------------------------------ | ------------------------------------------------------------------------ |
| `FormSource.FromSvg(string xml)`     | Creates a `FormSource` object from an SVG file provided as XML.          |
| `FormSource.FromSvg(byte[] svgData)` | Creates a `FormSource` object from an SVG file provided as a byte array. |
| `FormSource.FromSvg(Stream stream)`  | Creates a `FormSource` object from an SVG file provided as a stream.     |

The following example shows how to insert an SVG image into a `FormSource` object by using `FixedContentEditor`:

```C#
string svgFilePath = "image.svg";
RadFixedDocument fixedDocument = new RadFixedDocument();
FixedContentEditor documentPageEditor = new FixedContentEditor(fixedDocument.Pages.AddPage());
int offset = 10;
documentPageEditor.Position.Translate(offset, offset);

FormSource svgHostForm = FormSource.FromSvg(File.ReadAllBytes(svgFilePath));
documentPageEditor.DrawForm(svgHostForm);
//draw the SVG FormSource with its original size

double aspectRatio = svgHostForm.Size.Width / svgHostForm.Size.Height;
//get the aspect ratio from the original SVG size
double desiredSVGWidth = 100;
double calculatedSVGHeight = desiredSVGWidth / aspectRatio;
documentPageEditor.Position.Translate(offset, svgHostForm.Size.Height + offset);
documentPageEditor.DrawForm(svgHostForm, new Size(desiredSVGWidth, calculatedSVGHeight));
//draw the SVG FormSource with desired width preserving the aspect ratio
```

![RadPdfProcessing Insert SVG FormSource result](https://www.telerik.com/document-processing-libraries/documentation/assets/e792c3670a23872350afa65eaf88de16/pdf-processing-insert-svg.png)

## See Also

* [FormSource](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/model/formsource/overview)
* [Barcode FormSource](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/model/formsource/barcode)
