# Barcode FormSource

| Minimum Version | Q1 2025 |
| --------------- | ------- |

RadPdfProcessing supports adding barcodes (1D and 2D) into a PDF document. The static `FormSource.FromBarcode` and `FormSource.From2DBarcode` methods use the `Symbology1DType` and `Symbology2DType` enums that represent the different types of 1D and 2D barcode symbologies supported by the barcode model. The following overloads are available:

| Method                                                                                                  | Description                                                                                                                                                                                       |
| ------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `FormSource.FromBarcode(Symbology1DType symbology, string value)`                                       | Creates a `FormSource` object from one-dimensional (1D) barcode parameters, with a default `Width` and `Height` of 100.                                                                           |
| `FormSource.FromBarcode(Symbology1DType symbology, string value, int width, int height)`                | Creates a `FormSource` object from one-dimensional (1D) barcode parameters with custom `Width` and `Height`.                                                                                      |
| `FormSource.FromBarcode(Symbology1DType symbology, string value, int width, int height, bool showText)` | Creates a `FormSource` object from one-dimensional (1D) barcode parameters with custom `Width` and `Height` while specifying whether to show the text (`showText` is `false` by default).         |
| `FormSource.FromBarcode(Symbology1DType symbology, string value, bool showText)`                        | Creates a `FormSource` object from one-dimensional (1D) barcode parameters while specifying whether to show the text (`showText` is `false` by default). `Width` and `Height` are 100 by default. |
| `FormSource.From2DBarcode(Symbology2DType symbology, string value)`                                     | Creates a `FormSource` object from two-dimensional (2D) barcode parameters, with a default `Width` and `Height` of 100.                                                                           |
| `FormSource.From2DBarcode(Symbology2DType symbology, string value, int width, int height)`              | Creates a `FormSource` object from two-dimensional (2D) barcode parameters, with custom `Width` and `Height`.                                                                                     |

The following example shows how to create a barcode as a `FormSource` object and insert it in a page by using the [FixedContentEditor](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/editing/fixedcontenteditor):

```C#
RadFixedDocument doc = new RadFixedDocument();
FixedContentEditor documentPageEditor = new FixedContentEditor(doc.Pages.AddPage());

documentPageEditor.Position.Translate(0, 0);
FormSource barcode = FormSource.FromBarcode(Symbology1DType.Code128, "1234567890", width: 100, height: 100);
documentPageEditor.DrawForm(barcode, 100, 100);

documentPageEditor.Position.Translate(120, 0);
FormSource barcodeWithCenterCenterText = FormSource.FromBarcode(Symbology1DType.Code128, "1234567890", showText: true);
documentPageEditor.DrawForm(barcodeWithCenterCenterText, 100, 100);

documentPageEditor.Position.Translate(240, 0);
FormSource swissQr = FormSource.From2DBarcode(Symbology2DType.SwissQR, "1234567890");
documentPageEditor.DrawForm(swissQr, 100, 100);

documentPageEditor.Position.Translate(360, 0);
FormSource qr = FormSource.From2DBarcode(Symbology2DType.QR, "1234567890");
documentPageEditor.DrawForm(qr, 100, 100);
```

![RadPdfProcessing Insert Barcode FormSource result](https://www.telerik.com/document-processing-libraries/documentation/assets/4a67588c4a9b898ffdd245f93d03d5a1/pdf-processing-insert-barcode.png)

## See Also

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