GithubHelp home page GithubHelp logo

Comments (5)

veghp avatar veghp commented on May 28, 2024 1

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">&lt;John Saverilo&gt;</span>
</span>

label

For more customization, see the online documentations on html and css.

from blabel.

veghp avatar veghp commented on May 28, 2024 1

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.

from blabel.

noppGithub avatar noppGithub commented on May 28, 2024 1

@veghp Thanks so much, after reading your guide + some tweaks, now my task is done.

from blabel.

noppGithub avatar noppGithub commented on May 28, 2024

@veghp

Thank you so much for the prompt response, your solution is working.
But I still need to add 2 options.

  • Change the font to my local TTF, OTF file
  • Put all of the labels in a single A4 page.

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">&lt;{{ ID_NUM }}&gt;</span>
</span>

from blabel.

noppGithub avatar noppGithub commented on May 28, 2024

Resolution is valid and tested

from blabel.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.