def render_to_file(self, filename, items, **kwargs): """ Render labels to a PDF file """ records = self.get_record_data(items) writer = LabelWriter(self.template) writer.write_labels(records, filename)
def generate_label(products, filename): 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(products, target=filename + '.pdf', base_url='.')
def render(self, items, **kwargs): """ Render labels to an in-memory PDF object, and return it """ records = self.get_record_data(items) writer = LabelWriter(self.template) buffer = io.BytesIO() writer.write_labels(records, buffer) return buffer
def writeLabels(excelFile, templateFile, stylesheet=None): assets = list() try: dataframe = pandas.read_excel(excelFile, dtype='str') except: print("Unknown Exception: Failed to load spreadsheet.") return False records = dataframe.to_dict(orient='record') label_writer = LabelWriter(templateFile, default_stylesheets=(stylesheet)) label_writer.write_labels(assets, target="export.pdf") return True
def generate_barcode_label(self): from blabel import LabelWriter label_writer = LabelWriter( "barcode_template.html", default_stylesheets=("barcode_style.css",), ) records = [self.barcode_record] return label_writer.write_labels(records, target=None)
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_date.pdf")
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')
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="logo_and_datamatrix.pdf", base_url=".")
from blabel import LabelWriter label_writer = LabelWriter("item_template.html", default_stylesheets=("style.css", )) label_text_entries = [{ "desc": "M3 Flathead Socket Head Cap Screw, 8mm long", "vendor": "McMaster-Carr", "vendor_num": "92125A128", "url": "https://www.mcmaster.com/92125A128", } # Add more dictionary entries to this list here. ] label_writer.write_labels(label_text_entries, target="label.pdf")
from blabel import LabelWriter import pydenticon import base64 def generate_identicon(sample_id): identicon_generator = pydenticon.Generator( 6, 6, foreground=['red', 'blue', 'green', 'purple']) img = identicon_generator.generate(sample_id, 60, 60) return 'data:image/png;base64,%s' % (base64.b64encode(img).decode()) label_writer = LabelWriter("item_template.html", default_stylesheets=("style.css", ), generate_identicon=generate_identicon) records = [ dict(sample_id="s01", sample_name="Sample 1"), dict(sample_id="s02", sample_name="Sample 2"), dict(sample_id="s03", sample_name="Sample 3") ] label_writer.write_labels(records, target='barcode_and_dynamic_picture.pdf')
from blabel import LabelWriter label_writer = LabelWriter("item_template.html", items_per_page=3, default_stylesheets=("style.css",)) records= [ dict(name="Scott", sex="M"), dict(name="Laura", sex="F"), dict(name="Jane", sex="F"), dict(name="Valentin", sex="M"), dict(name="Hille", sex="F") ] label_writer.write_labels(records, target='several_items_per_page.pdf', base_url='.')
from blabel import LabelWriter import pandas dataframe = pandas.read_csv('records.csv') records = dataframe.to_dict(orient='record') label_writer = LabelWriter("item_template.html", default_stylesheets=("style.css", )) label_writer.write_labels(records, target='labels_from_spreadsheet.pdf')
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='logo_and_datamatrix.pdf', base_url='.')
from blabel import LabelWriter label_writer = LabelWriter("item_template.html", items_per_page=3, default_stylesheets=("style.css", )) records = [ dict(name="Scott", sex="M"), dict(name="Laura", sex="F"), dict(name="Jane", sex="F"), dict(name="Valentin", sex="M"), dict(name="Hille", sex="F"), ] label_writer.write_labels(records, target="several_items_per_page.pdf", base_url=".")