VintaSoft Barcode .NET SDK 16.0: Руководство для .NET разработчика
В этом разделе
Генерация векторного штрих-кода в виде файла с SVG изображением
В этом разделе
Вот пример C#/VB.NET кода, который показывает, как создать векторный штрих-код в виде файла с SVG изображением.
/// <summary>
/// Returns a barcode in vector form as Vintasoft.Barcode.BarcodePathData object.
/// </summary>
/// <param name="barcodeType">Barcode type.</param>
/// <param name="barcodeValue">Barcode value.</param>
/// <param name="svgFilename">The filename of SVG file to save.</param>
public static void SaveBarcodeAsSvgImage(Vintasoft.Barcode.BarcodeType barcodeType, string barcodeValue, string svgFilename)
{
    // create the barcode writer
    using (Vintasoft.Barcode.BarcodeWriter barcodeWriter = new Vintasoft.Barcode.BarcodeWriter())
    {
        // set barcode writer settings
        barcodeWriter.Settings.Barcode = barcodeType;
        barcodeWriter.Settings.Value = barcodeValue;

        // generate SVG file
        string svgFile = barcodeWriter.GetBarcodeAsSvgFile();
        
        // save SVG file
        System.IO.File.WriteAllText(svgFilename, svgFile);
    }
}
''' <summary>
''' Returns a barcode in vector form as Vintasoft.Barcode.BarcodePathData object.
''' </summary>
''' <param name="barcodeType">Barcode type.</param>
''' <param name="barcodeValue">Barcode value.</param>
''' <param name="svgFilename">The filename of SVG file to save.</param>
Public Shared Sub SaveBarcodeAsSvgImage(barcodeType As Vintasoft.Barcode.BarcodeType, _
    barcodeValue As String, svgFilename As String)

    ' create the barcode writer
    Using barcodeWriter As New Vintasoft.Barcode.BarcodeWriter()
        ' set barcode writer settings
        barcodeWriter.Settings.Barcode = barcodeType
        barcodeWriter.Settings.Value = barcodeValue

        ' generate SVG file
        Dim svgFile As String = barcodeWriter.GetBarcodeAsSvgFile()

        ' save SVG file
        System.IO.File.WriteAllText(svgFilename, svgFile)
    End Using
End Sub