VintaSoft Barcode .NET SDK 14.3: Documentation for .NET developer
In This Topic
    Get barcode image as SVG image file
    In This Topic
    Example: Here is an example that shows how to generate barcode in vector form as SVG image file.
    /// <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