Created
April 13, 2022 20:04
-
-
Save MarcManiez/bd2205d78b8087784e6870fd294da3eb to your computer and use it in GitHub Desktop.
pylabels PACKZON label sheet spec
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import labels | |
from reportlab.graphics import shapes | |
# This gist shows how to print data onto PACKZON label sheets. This gist depends on two libraries: pylabels, and reportlab, which also have a few peer dependencies. See their documentation for install instructions. | |
# https://www.amazon.com/PACKZON-Address-Labels-Adhesive-Printers/dp/B08J2W38Q2/ref=sr_1_2?qid=1649604929&sr=8-2&srs=14033504011&th=1 | |
# PACKZON dimensions INCHES | MILLIMETERS | |
# 750 Labels 2.625" x 1" | 66.675mm x 25.4mm | |
# Specifications: | |
# Label Size: 2.625" x 1" | 66.675mm x 25.4mm | |
# Sheet Size: 8.5" x 11" | 215.9mm x 279.4mm | |
# Shape: Round Corner Rectangle | |
# Top Margin: 0.5" | 12.7mm | |
# Bottom Margin: 0.5" | 12.7mm | |
# Left Margin: 0.1875" | 4.7625mm | |
# Right Margin: 0.1875" | 4.7625mm | |
# Vertical Spacing: 0 | 0mm | |
# Horizontal Spacing: 0.125" | 3.175mm | |
# In order, this function takes page width, page height, columns, rows, label width, label height | |
specs = labels.Specification(215.9, 279.4, 3, 10, 66.675, 25.4, corner_radius=2, row_gap=0, column_gap=3.175) | |
# Draw labels here using data from `obj` | |
def draw_label(label, width, height, obj): | |
# First two args are coordinates, starting from the bottom left | |
s = shapes.String(0, 0, 'Hello world') | |
label.add(s) | |
sheet = labels.Sheet(specs, draw_label, border=True) | |
# Replace with data you wish to label | |
data = [] | |
for datum in data: | |
sheet.add_label(datum) | |
sheet.save('labels.pdf') | |
print("{0:d} label(s) output on {1:d} page(s).".format( | |
sheet.label_count, sheet.page_count)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment