Skip to content

Implement N-up label printing - #995

Open
d-buchmann wants to merge 14 commits into
Part-DB:masterfrom
d-buchmann:label_printing_on_A4
Open

d-buchmann wants to merge 14 commits into
Part-DB:masterfrom
d-buchmann:label_printing_on_A4

Conversation

@d-buchmann

@d-buchmann d-buchmann commented Aug 14, 2025 •

Copy link
Copy Markdown
Contributor

Make label printing more flexible by allowing to put multiple labels onto a single PDF page in a grid ("N-up printing").
This way you can use e.g. A4 sheets with pre-cut labels and print them in your household inkjet/laser printer - no need for a special label printer.

The grid of the sheet is set by xcount and ycount which I added to the form (but not yet to the database).
You can also set a skipcount which skips the given number of labels in case you have partly printed sheets from previous prints (feature as described/requested in #577).
The size and position tweaking can be done in the additional css to fit any label sheet type.

As far as I have tested, it doesn't break the original behavior using the default values xcount=ycount=1, skipcount=0.
Currently, only translations are yet to be added.

@codecov

codecov Bot commented Aug 14, 2025 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 78.57143% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 62.75%. Comparing base (de2f3cb) to head (daf6335).
⚠️ Report is 17 commits behind head on master.

Files with missing lines Patch % Lines
src/Entity/LabelSystem/LabelOptions.php 40.00% 9 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master     #995      +/-   ##
============================================
+ Coverage     62.39%   62.75%   +0.35%     
- Complexity     9879     9897      +18     
============================================
  Files           736      736              
  Lines         31779    31852      +73     
============================================
+ Hits          19829    19988     +159     
+ Misses        11950    11864      -86     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@d-buchmann
d-buchmann marked this pull request as ready for review July 29, 2026 10:33
@z3ugma

z3ugma commented Sep 10, 2026

Copy link
Copy Markdown

I would benefit a lot from this PR getting merged. What do you think @jbtronics ?

Comment thread src/Entity/LabelSystem/LabelOptions.php Resolved
Improve naming and last row completion.

But I introduced a regression that prevents me from printing more than one page.
Sorry, not ready yet :/
Now it should be much more consistent and maintainable.
- Reduce skip count modulo full pages
- Set up associative arrays for header and trailer with key = index, value = null
- Merge header, content and trailer
- Loop through the resulting array, only adding row handling and pagination

Found the bug that made page breaks fail sometimes: a missing closing div...
@francisrath

Copy link
Copy Markdown

Thanks for starting this, printing whole A4 sheets of labels is something I've wanted for a while!

I built a few things on top of your branch and opened them as a PR against it: d-buchmann#4

  • labels placed at exact mm positions instead of a table (and single-label output unchanged),
  • a catalog of common label sheets (Avery, Zweckform, HERMA, APLI, Sigel, Pimaco, …) you can pick from the profile, with the values from the manufacturers' data,
  • optionally remembering where the next free label on a partly used sheet is.

Each part is its own commit, so feel free to take any or none of it. Since there are now several migrations, I'm happy to merge them into a single one with yours if you decide to take the changes.

francisrath and others added 6 commits November 30, 2026 13:05
…eets (#4)

Replace the CSS-based N-up grid with exact sheet geometry: page size,
margins to the first label and horizontal/vertical pitch, so labels land
on the pre-cut positions of office label sheets. The placement logic moves
from the Twig template into LabelHTMLGenerator.

Add a built-in catalog of common A4 and US Letter sheets (Avery, Avery
Zweckform, HERMA) in config/label_sheets.yaml, selectable in the label
generator and the label profile. Custom sheets keep working; a sheet size
or pitch of 0 is derived from the label size.

All label profile columns (grid, sheet, geometry) are added in a single
migration. Document label sheets in docs/usage/labels.md.
@d-buchmann

Copy link
Copy Markdown
Contributor Author

@z3ugma would you consider another review? Code changed substantially under the hood, while maintaining and improving the proposed functionality.

This branch has not been deployed

No deployments
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.

3 participants