You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何编程Zebra TLP 2824 Plus打印并排1×1英寸条码标签

Hey there! Let's break this down and get your 1"×1" side-by-side labels working with your Zebra TLP 2824 Plus. Since you're new to label printers, I'll keep this clear and actionable—your initial thought to use ZPL is spot-on, because native ZPL gives you far more control over label layout than generating HTML/SVG and relying on browser printing.

First: Understand the Printer & Label Dimensions

Your TLP 2824 Plus has a maximum print width of 2.25 inches (≈57mm), which fits two 1" labels with a small 0.25" gap between them perfectly. We'll use ZPL to define each label's position, barcode, and layout directly.

Step 1: Build the ZPL Template for Two 1"×1" Labels per Row

Here's a custom ZPL snippet tailored to your needs. I'll explain each part so you can tweak it if needed:

^XA
^LL203          ! Set label length to 1 inch (203 dots, matches the printer's 203 DPI density)
^BY2            ! Set barcode module width (2 dots = standard thickness)
^FO10,10^BCN80,Y,N ! Left label: Code 128 barcode, height 80 dots, human-readable text enabled
^FDSESSION_ID_HERE^FS ! Replace with your actual Session ID
^FO10,100^A0N20,20^FDSESSION_ID_HERE^FS ! Optional: Session ID text below barcode

^FO140,10^BCN80,Y,N ! Right label: Offset 140 dots from left (leaves ~0.25" gap between labels)
^FDSESSION_ID_HERE^FS
^FO140,100^A0N20,20^FDSESSION_ID_HERE^FS
^XZ
  • ^LL203: Sets the total label height to 1 inch (203 DPI × 1 inch = 203 dots)
  • ^FO10,10: Field origin (x,y) for the left label's barcode—10 dots from left, 10 dots from top (adds small padding)
  • ^BCN80,Y,N: ^BC = Code 128 barcode, N = normal orientation, 80 = barcode height (adjust if needed), Y = print human-readable text below the barcode, N = no check digit
  • ^FO140,10: Right label's starting x-position—places it just far enough from the left label to leave a small gap

Step 2: Modify Your Web Code to Generate & Print ZPL

Instead of generating SVG barcodes and HTML, we'll generate the ZPL dynamically based on the user's input, then send it to the printer. Here's how to update your printDiv function:

function printDiv() {
    // Get user inputs
    var txt = $find("<%= txtSessionID.ClientID %>");
    var sessionID = txt._savedValidationValue;
    var cbo = $find("<%= cboNumOfLabels.ClientID %>");
    var totalLabels = parseInt(cbo._value);

    // Build ZPL content
    let zpl = "^XA^LL203^BY2"; // Base config: 1" height, barcode thickness 2
    let labelsPrinted = 0;

    while (labelsPrinted < totalLabels) {
        // Add left label
        zpl += `^FO10,10^BCN80,Y,N^FD${sessionID}^FS^FO10,100^A0N20,20^FD${sessionID}^FS`;
        labelsPrinted++;

        // Add right label if we haven't reached the total count
        if (labelsPrinted < totalLabels) {
            zpl += `^FO140,10^BCN80,Y,N^FD${sessionID}^FS^FO140,100^A0N20,20^FD${sessionID}^FS`;
            labelsPrinted++;
        }

        // Start a new row if we need to print more labels
        if (labelsPrinted < totalLabels) {
            zpl += "^XZ^XA^LL203^BY2"; // End current row, initialize new row config
        }
    }

    zpl += "^XZ"; // End final ZPL block

    // Print the ZPL: Create a hidden text area with ZPL content, then trigger print
    let printArea = document.createElement('textarea');
    printArea.style.position = 'absolute';
    printArea.style.left = '-9999px';
    printArea.value = zpl;
    document.body.appendChild(printArea);
    printArea.select();
    window.print();
    document.body.removeChild(printArea);

    // No need for location.reload() anymore—ZPL print won't break the combo box
}
  • We loop through the total number of labels, adding two per row until we reach the desired count
  • We use a hidden textarea to hold the ZPL content—browsers will print this plain text, and your Zebra printer will interpret it directly as label instructions

Step 3: Configure Your Zebra Printer

Before testing, make sure your printer is set up correctly in Zebra Setup Utilities:

  • Go to Media Settings and set the label size to 1" × 1"
  • Set the Media Type to match your labels (e.g., "Gap/Notch" if your labels have gaps between them, "Continuous" if they're on a roll without gaps)
  • Confirm the printer is set to ZPL Mode (this is usually the default, but double-check in the printer's advanced settings)

Testing Tips

  • Use Zebra Setup Utilities' ZPL Test Tool to paste your generated ZPL and print a test label first—this helps confirm the ZPL is correct before integrating it into your web code
  • Start with a small number of labels (e.g., 2 or 3) to test the layout and spacing

Why This Is Better Than Your Original Approach

Your original HTML/SVG method relies on browser rendering, which can be inconsistent with label printers. ZPL is the native language for Zebra printers, so it will give you precise control over every element of your labels, including spacing, barcode size, and text placement.

内容的提问来源于stack exchange,提问作者Jmendez

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.08 16:52:59