homebox-label-template/generate_labels.py
2024-01-13 03:38:56 +01:00

26 lines
846 B
Python
Executable file

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import svgwrite
def create_a4_svg(output_filename):
# A4 size in millimeters
a4_width = '210mm'
a4_height = '297mm'
# Create SVG document (A4)
dwg = svgwrite.Drawing(output_filename, size=(a4_width, a4_height), profile='tiny')
# Add your content or elements to the SVG here
# For example, you can add a rectangle as a placeholder
# dwg.add(dwg.rect(insert=(10, 10), size=(a4_width_svg - 20, a4_height_svg - 20), fill="white", stroke="black"))
for x in range(0,3):
for y in range(0,10):
print(f"Create Label: X={x}, Y={y}")
dwg.add(dwg.rect(insert=(f'{x*70}mm', f'{y*29.7}mm'), size=('70mm', '29.7mm'), fill="red", stroke="none"))
# Save the SVG document
dwg.save()
if __name__ == "__main__":
create_a4_svg("output_a4.svg")