## IBarcodeGenerator.GetBarcodeImage method

Generate barcode image using the set of parameters (for DisplayBarcode field).

```csharp
public Stream GetBarcodeImage(BarcodeParameters parameters)
```

| Parameter | Type | Description |
| --- | --- | --- |
| parameters | BarcodeParameters | The set of parameters |

### Return Value

Stream with image data representing generated barcode.

## Remarks

Supported image formats are Bmp, Emf, Gif, Jpeg, Png, Tiff, Wmf, Pict, Ico, WebP, Svg.

## Examples

Shows how to use a barcode generator.

```csharp
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// We can use a custom IBarcodeGenerator implementation to generate barcodes,
// and then insert them into the document as images.
doc.FieldOptions.BarcodeGenerator = new CustomBarcodeGenerator();

// Below are four examples of different barcode types that we can create using our generator.
// For each barcode, we specify a new set of barcode parameters, and then generate the image.
// Afterwards, we can insert the image into the document, or save it to the local file system.
// 1 -  QR code:
BarcodeParameters barcodeParameters = new BarcodeParameters
{
    BarcodeType = "QR",
    BarcodeValue = "ABC123",
    BackgroundColor = "0xF8BD69",
    ForegroundColor = "0xB5413B",
    ErrorCorrectionLevel = "3",
    ScalingFactor = "250",
    SymbolHeight = "1000",
    SymbolRotation = "0"
};

using (Stream img = doc.FieldOptions.BarcodeGenerator.GetBarcodeImage(barcodeParameters))
{
    using (FileStream fs = new FileStream(ArtifactsDir + "FieldOptions.BarcodeGenerator.QR.jpg", FileMode.Create))
    {
        img.CopyTo(fs);
    }

    img.Position = 0;
    builder.InsertImage(img);
}

// 2 -  EAN13 barcode:
barcodeParameters = new BarcodeParameters
{
    BarcodeType = "EAN13",
    BarcodeValue = "501234567890",
    DisplayText = true,
    PosCodeStyle = "CASE",
    FixCheckDigit = true
};

using (Stream img = doc.FieldOptions.BarcodeGenerator.GetBarcodeImage(barcodeParameters))
{
    using (FileStream fs = new FileStream(ArtifactsDir + "FieldOptions.BarcodeGenerator.EAN13.jpg", FileMode.Create))
    {
        img.CopyTo(fs);
    }

    img.Position = 0;
    builder.InsertImage(img);
}

// 3 -  CODE39 barcode:
barcodeParameters = new BarcodeParameters
{
    BarcodeType = "CODE39",
    BarcodeValue = "12345ABCDE",
    AddStartStopChar = true
};

using (Stream img = doc.FieldOptions.BarcodeGenerator.GetBarcodeImage(barcodeParameters))
{
    using (FileStream fs = new FileStream(ArtifactsDir + "FieldOptions.BarcodeGenerator.CODE39.jpg", FileMode.Create))
    {
        img.CopyTo(fs);
    }

    img.Position = 0;
    builder.InsertImage(img);
}

// 4 -  ITF14 barcode:
barcodeParameters = new BarcodeParameters
{
    BarcodeType = "ITF14",
    BarcodeValue = "09312345678907",
    CaseCodeStyle = "STD"
};

using (Stream img = doc.FieldOptions.BarcodeGenerator.GetBarcodeImage(barcodeParameters))
{
    using (FileStream fs = new FileStream(ArtifactsDir + "FieldOptions.BarcodeGenerator.ITF14.jpg", FileMode.Create))
    {
        img.CopyTo(fs);
    }

    img.Position = 0;
    builder.InsertImage(img);
}

doc.Save(ArtifactsDir + "FieldOptions.BarcodeGenerator.docx");
```

### See Also

* class [BarcodeParameters](../../barcodeparameters/)
* interface [IBarcodeGenerator](../)
* namespace [Aspose.Words.Fields](../../../aspose.words.fields/)
* assembly [Aspose.Words](../../../)
