Integrating 1C-Bitrix with Brother label printers

Our company is engaged in the development, support and maintenance of Bitrix and Bitrix24 solutions of any complexity. From simple one-page sites to complex online stores, CRM systems with 1C and telephony integration. The experience of developers is confirmed by certificates from the vendor.
Our competencies:
Development stages
Latest works
  • image_website-b2b-advance_0.png
    B2B ADVANCE company website development
    1183
  • image_bitrix-bitrix-24-1c_fixper_448_0.png
    Website development for FIXPER company
    813
  • image_bitrix-bitrix-24-1c_development_of_an_online_appointment_booking_widget_for_a_medical_center_594_0.webp
    Development based on Bitrix, Bitrix24, 1C for the company Development of an Online Appointment Booking Widget for a Medical Center
    564
  • image_bitrix-bitrix-24-1c_mirsanbel_458_0.webp
    Development based on 1C Enterprise for MIRSANBEL
    747
  • image_crm_dolbimby_434_0.webp
    Website development on CRM Bitrix24 for DOLBIMBY
    657
  • image_crm_technotorgcomplex_453_0.webp
    Development based on Bitrix24 for the company TECHNOTORGKOMPLEKS
    976

Integrating 1C-Bitrix with Brother Label Printers

Brother is an alternative to Zebra for office and light warehouse tasks. The QL series (thermal printing on DK rolls) and PT series (tape printers) are used where small label batches are needed: kit labelling, address labels for shipments, shelf labels. The key difference from Zebra is that Brother works primarily through the operating system's print subsystem (GDI/CUPS) rather than through RAW TCP/IP with ZPL.

Ways to Communicate with a Brother Printer

Option 1: Via the system printer (recommended for office use)

Brother is installed as a system printer on Windows or macOS. 1C-Bitrix generates a PDF or PNG of the required size and sends it to print via a system command:

function printLabelViaCups(string $pdfPath, string $printerName): bool
{
    $cmd = escapeshellcmd("lp -d " . escapeshellarg($printerName) . " " . escapeshellarg($pdfPath));
    exec($cmd . ' 2>&1', $output, $returnCode);
    return $returnCode === 0;
}

On Windows — similarly via SumatraPDF -print-to or mspaint /pt.

Option 2: Brother SDK / b-PAC (Windows only)

Brother provides a COM object, b-PAC, for working with .lbx templates in P-touch Editor. Integration via the PHP COM interface:

$doc = new COM('bpac.Document');
$doc->Open('C:\\Labels\\price_label.lbx');
$doc->GetObject('barcode')->Text  = $barcode;
$doc->GetObject('price')->Text    = number_format($price, 2, ',', ' ') . ' RUB';
$doc->GetObject('name')->Text     = $productName;
$doc->StartPrint('', 0);
$doc->PrintOut(1, 0);
$doc->EndPrint();
$doc->Close();

This approach only works if PHP is running on a Windows server with Brother P-touch Editor installed. It cannot be used on Linux production servers.

Option 3: Brother Web API (QL-820NWB and newer models)

Several networked Brother models have a web API. Documentation is model-specific, but the general principle is: HTTP POST with a base64-encoded image or PDF.

Label Rendering on the 1C-Bitrix Side

For Linux servers (Option 1), label images are generated using GD or Imagick:

class BrotherLabelRenderer
{
    public function renderPriceLabel(array $product, int $widthMm = 62, int $heightMm = 29): string
    {
        $dpi = 300;
        $wPx = (int)($widthMm / 25.4 * $dpi);
        $hPx = (int)($heightMm / 25.4 * $dpi);

        $image = imagecreatetruecolor($wPx, $hPx);
        $white = imagecolorallocate($image, 255, 255, 255);
        $black = imagecolorallocate($image, 0, 0, 0);
        imagefill($image, 0, 0, $white);

        // Product name (using a TTF font)
        $fontPath = $_SERVER['DOCUMENT_ROOT'] . '/local/fonts/DejaVuSans.ttf';
        imagettftext($image, 14, 0, 20, 60, $black, $fontPath, mb_substr($product['NAME'], 0, 35));

        // Price in large font
        $price = number_format($product['PRICE'], 2, ',', ' ') . ' RUB';
        imagettftext($image, 28, 0, 20, 120, $black, $fontPath, $price);

        // Barcode via library (picqer/php-barcode-generator)
        $barcodeGenerator = new \Picqer\Barcode\BarcodeGeneratorPNG();
        $barcodePng = $barcodeGenerator->getBarcode($product['BARCODE'], $barcodeGenerator::TYPE_EAN_13, 2, 60);
        $barcodeImg = imagecreatefromstring($barcodePng);
        imagecopy($image, $barcodeImg, 20, 150, 0, 0, imagesx($barcodeImg), imagesy($barcodeImg));

        $tmpPath = sys_get_temp_dir() . '/label_' . $product['ID'] . '_' . time() . '.png';
        imagepng($image, $tmpPath);
        imagedestroy($image);
        return $tmpPath;
    }
}

Print Queue for Brother

Unlike Zebra (where TCP transmission is fast), printing via the system printer takes time. The same queue architecture is used with bl_brother_print_queue:

CREATE TABLE bl_brother_print_queue (
    id           SERIAL PRIMARY KEY,
    printer_name VARCHAR(128) NOT NULL,  -- CUPS printer name
    template     VARCHAR(64) NOT NULL,
    product_id   INT,
    data_json    JSONB,
    copies       SMALLINT DEFAULT 1,
    status       VARCHAR(20) DEFAULT 'pending',
    created_at   TIMESTAMP DEFAULT NOW(),
    processed_at TIMESTAMP
);

A 1C-Bitrix agent picks jobs from the queue, renders a PNG via BrotherLabelRenderer, and sends it to CUPS.

Integration with the Administrative Interface

A "Print label" button is added to the product card in 1C-Bitrix admin — it adds a job to the queue with a printer selection from the list (bl_brother_printers). When multiple products are selected in the list view, a bulk action "Print labels" becomes available.

A "Print labels for shipped order" button is added to the admin order card: it generates an address label (name, address, order number) and kit assembly labels.

Timeline

Phase Duration
Label renderer (GD/Imagick + TTF) 2 days
Print queue + agent 1 day
CUPS / system printer integration 1 day
Buttons in product and order cards 2 days
Testing with a real Brother printer 1 day
Total 7–9 days