Skip to content

fix: restore barcode text population for QR code objects#41

Open
ji-kwon-sherpas wants to merge 1 commit into
yeasir01:mainfrom
ji-kwon-sherpas:fix/barcode-text-population
Open

fix: restore barcode text population for QR code objects#41
ji-kwon-sherpas wants to merge 1 commit into
yeasir01:mainfrom
ji-kwon-sherpas:fix/barcode-text-population

Conversation

@ji-kwon-sherpas

Copy link
Copy Markdown

Problem

In v3.0.0, QR code (barcode) objects in templates are not being populated with the provided data. Instead, the default value hardcoded in the .lbx template file is printed/previewed.

This is a regression from v2.2.0, which had the changelog entry: "Patched a bug where QR codes were not being populated".

Root Cause

In v2.2.0, populateObjectsInTemplate handled barcode objects with both obj.Text = value and Doc.SetBarcodeData():

// v2.2.0 (working)
case ObjectTypes.Barcode:
    const barcodeIndex = await Doc.GetBarcodeIndex(key);
    obj.Text = value;                              // ← sets the barcode data
    await Doc.SetBarcodeData(barcodeIndex, value);
    break;

During the v3.0.0 refactor, obj.Text = value was removed:

// v3.0.0 (broken)
case ObjectTypes.Barcode:
    const barcodeIndex = await Doc.GetBarcodeIndex(key);
    await Doc.SetBarcodeData(barcodeIndex, value); // ← only method left
    break;

The problem is that Doc.GetBarcodeIndex(key) returns undefined for QR code objects. This causes Doc.SetBarcodeData(undefined, value) to silently do nothing — no error is thrown, but the barcode data is never updated.

Fix

Replace the broken GetBarcodeIndex + SetBarcodeData approach with obj.Text = value, which correctly sets data for all barcode types including QR codes via IObject::SetText. This matches the working behavior from v2.2.0.

case ObjectTypes.Barcode:
    obj.Text = value;
    break;

Testing

Verified with Brother PT-P900W using .lbx templates containing QR code objects:

  • QR code data is now correctly populated in both preview (getImageData) and print (print)
  • Text, Image, and other object types continue to work as expected

In v2.2.0, barcode objects were populated using `obj.Text = value` in
addition to `Doc.SetBarcodeData()`. The `obj.Text` assignment was
removed during the v3.0.0 refactor, causing QR code objects to retain
their default template values instead of being updated with the
provided data.

`Doc.GetBarcodeIndex(key)` returns `undefined` for QR code objects,
which causes `Doc.SetBarcodeData(undefined, value)` to silently fail.
Since `IObject::SetText` correctly sets barcode data (including QR
codes), this commit replaces the broken `GetBarcodeIndex` +
`SetBarcodeData` approach with the simpler and working `obj.Text`
assignment, matching the behavior from v2.2.0.
@yeasir01

Copy link
Copy Markdown
Owner

Thanks for that. Could you provide a bit more detail? Specifically, what type of barcode was used, and a sample of the data for reference?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants