Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Printing multiple labels #23

Closed
rickbps opened this issue Oct 24, 2022 · 4 comments
Closed

Printing multiple labels #23

rickbps opened this issue Oct 24, 2022 · 4 comments

Comments

@rickbps
Copy link

rickbps commented Oct 24, 2022

I see in the documentation that it is possible to print two labels sequentially by using two separate dicts.

If I have x number of records in a table and want to loop through them, is it possible to print them on one PDF?

@veghp
Copy link
Member

veghp commented Oct 25, 2022

Can you please point to that part of documentation and also clarify what you mean? What format (Python object) do you have your table in?

There are examples in https://github.com/Edinburgh-Genome-Foundry/blabel/tree/master/examples for printing several items per page, reading from spreadsheet etc

@rickbps
Copy link
Author

rickbps commented Oct 26, 2022

Hello,

The documentation shows how to print two labels on one PDF as follows:

`from blabel import LabelWriter

label_writer = LabelWriter("item_template.html",
default_stylesheets=("style.css",))
records= [
dict(sample_id="s01", sample_name="Sample 1"),
dict(sample_id="s02", sample_name="Sample 2")
]

label_writer.write_labels(records, target='qrcode_and_label.pdf')`

My requirements are:

  • Users go to a PHP page that interacts with a MYSQL database.
  • On the page, they can filter a long list of items by ID number
  • They could, for example, end up with a group of 6 items that share a common ID number
  • Right now, my page has a button for each item that uses blabel to print a label for each item
  • What I would like to do is have one button that prints all six lables (or whatever the item count is) on one PDF

@veghp
Copy link
Member

veghp commented Oct 28, 2022

I see the problem now. The package is designed around a fixed PDF page or label size as that's how label printers (or printers in general) operate. But you have variable number of items, which means different PDF sizes. As I mentioned, it's possible to print several items per page, or see this example: #6

And here is an example for working from tables (spreadsheet / dataframe): https://github.com/Edinburgh-Genome-Foundry/blabel/tree/c95052f562af44ef47e2ec5b220ffbb3b721659b/examples/labels_from_spreadsheet

Alternatively you can work directly with WeasyPrint or PDF Reports.

@rickbps
Copy link
Author

rickbps commented Oct 28, 2022

The printing from table/label is closest to what I need, so maybe I can use that. Thank you.

@rickbps rickbps closed this as completed Oct 28, 2022
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

No branches or pull requests

2 participants