feat(docx): write a barcode as a picture that scans - #736
Merged
Merged
Conversation
The export dropped a BarcodeNode with the geometry-only nodes, so a receipt, a ticket or a shipping label lost the code a reader scans. It is now a PNG of the same ZXing matrix the PDF and PPTX backends draw, through BarcodeMatrices: one pixel a cell, in the symbol's two colours with their alpha, encoded in memory, at the node's size, with its margin as the space around it, its anchor as a bookmark and its data as the picture's description. A barcode in two transparent colours still holds its space. The report calls it APPROXIMATED, since the data is part of the picture, and names a link or a transform on it as not carried. To reach BarcodeMatrices, render-docx takes render-pdf at compile scope, as render-pptx does. The README, class Javadoc, package map, the v2.5.0 Packaging entry, troubleshooting and ROADMAP are brought in line.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The DOCX export dropped a
BarcodeNodealong with the geometry-only nodes. A receipt, a ticket or a shipping label lost the code a reader scans, and the report showed it asDROPPED.What changed
writeBarcode, newDocxBarcodePictures).BarcodeMatrices, so the three backends cannot encode one symbol differently.anchoris a bookmark, viablockAnchorOf, so a page reference to it resolves.ImageWriteron aMemoryCacheImageOutputStream.ImageIO.writeto a stream caches through a temp file by default, and that per-barcode cost is the spike the PDF backend's barcodes were measured paying before they became vectors. On the probe, a 90pt QR code is 445 bytes.docPr/@descr), for a screen reader.APPROXIMATED, because the data is part of the picture and cannot be edited in Word. The note also says when a link or a transform on the barcode is not carried.graph-compose-render-docxnow takesgraph-compose-render-pdfat compile scope, asgraph-compose-render-pptxdoes, to reachBarcodeMatrices. It was at runtime scope, and only on the unreleased 2.5 line; 2.4.x declared it at test scope. The v2.5.0 Packaging entry is amended rather than contradicted.troubleshooting.mdandROADMAP.md, which listed barcodes as dropped;render-docx/README.md, the backend's class Javadoc andpackage-map.md, which said runtime scope;Verification
In an editor. A 90pt QR code and a 180×45pt Code 128 in a brand colour, each with a top margin, between two paragraphs. Rendered by the engine and converted with LibreOffice, both land at the page's size and position, in their colours.
Tests.
./mvnw -B -ntp test -pl :graph-compose-render-docx→ 365 run, 0 failures. NewDocxBarcodeTest(11):BarcodeMatricesmatrix, one pixel a cell, checked cell by cell;w:before;APPROXIMATEDwith nothingDROPPED, and a link is named as not carried.Each of these was sabotaged and fails its test:
Gate. Full reactor gate (
clean verifyover core, render-pdf/docx/pptx, templates, testing, qa, coverage) → BUILD SUCCESS (qa 1788 green). Examples after install: 93 green; no committed preview moved.Notes
scripts/release-smoke/s8-core-render-docxstill states that render-docx declares render-pdf at test scope. That has been stale since build(render-docx): bring the PDF backend so the DOCX module works on its own #722 and is release tooling. Its explicit render-pdf dependency still resolves.Lane: shared-engine (render-docx) + build (render-docx pom). No public API change.