Démonstration - Interleaved 2 of 5

* 30 caractères maximum pour cette démo.
'use strict';

import { createServer } from 'http';
import {
    BCGColor,
    BCGDrawing,
    BCGFont,
    BCGLabel,
    createSurface,
    toBuffer
} from '@barcode-bakery/barcode-nodejs';
import { BCGi25 } from '@barcode-bakery/barcode-nodejs/1d';

http.createServer(function (request, response) {
    const font = new BCGFont('Arial', 18);
    const colorBlack = new BCGColor(0, 0, 0);
    const colorWhite = new BCGColor(255, 255, 255);

    // Barcode Part
    const code = new BCGi25();
    code.setScale(2); // Resolution
    code.setThickness(30); // Thickness
    code.setForegroundColor(colorBlack); // Color of bars
    code.setBackgroundColor(colorWhite); // Color of spaces
    code.setFont(font); // Font
    code.parse('1234');

    // Drawing Part
    const drawing = new BCGDrawing(createSurface);
    toBuffer(drawing, BCGDrawing.ImageFormat.Png, function (err, buffer) {
        response.writeHead(200, { "Content-Type": "image/png" });
        response.end(buffer);
    });
}).listen(8124);