Closed noppGithub closed 3 years ago
There are many ways to do it; for example edit style.css
to resize label and add "right" class:
@page {
width: 35mm;
height: 11mm;
padding: 0.5mm;
}
img {
height: 6.4mm;
display: inline-block;
vertical-align: middle;
image-rendering: pixelated;
}
.label {
font-family: Ubuntu;
font-weight: bold;
vertical-align: middle;
display: inline-block;
font-size: 7px;
}
.right{
float:right;
}
And the template html:
<img src="{{label_tools.qr_code(sample_id)}}"/>
<span class='label'>
{{ sample_name }} <br/>
52/3 Avenue road, <br/>
Chumpo district, <br/>
Lamgo province 19456 <br/>
<span class="right"><John Saverilo></span>
</span>
For more customization, see the online documentations on html and css.
@veghp
Thank you so much for the prompt response, your solution is working. But I still need to add 2 options.
My current code is below, and the current result is attached, I want to put all the labels in a single A4 page(s) Files:
my_blabel.py
from blabel import LabelWriter
import pandas
df = pandas.read_excel("file.xlsx")
df = df.iloc[:100,:]
records = df.to_dict(orient="records")
label_writer = LabelWriter("item_template.html", default_stylesheets=("style.css",))
label_writer.write_labels(records, target="labels_from_spreadsheet.pdf")
style.css
@page {
width: 297mm;
height: 420mm;
padding: 4.5mm;
}
img {
height: 6.4mm;
display: inline-block;
vertical-align: middle;
image-rendering: pixelated;
}
.label {
font-family: Ubuntu;
font-weight: bold;
vertical-align: middle;
display: inline-block;
font-size: 7px;
}
.right{
float:right;
}
item_template.html
<span class='label'>
{{ FIRST_NAME }} {{ SURNAME }} <br/>
{{ ADDLINE1 }}, <br/>
{{ ADDLINE2 }}, <br/>
{{ ADDLINE3 }} {{ ZIPCODE }} <br/>
<span class="right"><{{ ID_NUM }}></span>
</span>
To change the font, replace "Ubuntu" in the css file with the font that you want to use and is installed on the system.
Putting multiple items on a page is covered in the examples, see the Python and css files in this folder: https://github.com/Edinburgh-Genome-Foundry/blabel/tree/master/examples/several_items_per_page Let me know if this solves the problem.
@veghp Thanks so much, after reading your guide + some tweaks, now my task is done.
Resolution is valid and tested
I want to create labels with the following contents. Is it possible to do ?