lablie
lablie
is designed to be simply usable tool to prepare documents with labels for printing.
The main features are:
- instance SVG template with provided data,
- tile SVG to meet specified print-paper layout,
- project support for complex usages.
License
The project is licensed under Apache License, Version 2.0, January 2004.
Installation
Snap package
The tool is packaged as snap package at snapcraft.io, and can be installed with:
sudo snap install lablie
Native distribution package
Not packaged, yet.
From sources
No manual way, yet.
Command Line Tool
Command line tool lablie
groups multiple sub-commands to work with labels:
- instance command instantiates SVG template with provided data,
- tile SVG to meet specified print-paper layout,
- project support for complex usages.
Reference
Output of the lablie --help
:
Usage: lablie [-hv] [COMMAND]
Tool to generate documents with labels for printing.
-h, --help display a help message
-v, --version display version info
Commands:
tile Tile labels
instance Fill label template with instance data
project Group command for project manipulation sub-commands
lablie tile
command
The command tile
creates SVG document with tiled labels based on paper's and label's specifications.
Reference
See output of the lablie tile --help
:
Usage: lablie tile [OPTIONS] SOURCE TARGET
Tile labels
SOURCE Path to SVG file containing a label
TARGET Path to SVG file which should be generated
--dataset-csv FILE Path to CSV file containing instances
--dataset-csv-format FORMAT
Sets format for parsing CSV dataset (available options:
Default, Excel, InformixUnload, InformixUnloadCsv,
MySQL, PostgreSQLCsv, PostgreSQLText, RFC4180, TDF)
--dataset-json FOLDER Path to folder containing JSON files for instances
--instance KEY Key of instance to be rendered
--instance-json FILE Path to JSON file containing values for single instance
--instances-json FILE Path to JSON file containing array of instances (can be
used in combination with --dataset-json)
--label-delta mm mm X and Y delta between labels in mm, ie. 5 5
--label-offset mm mm X and Y offset of the first label in mm, ie. 5 5
--label-size mm mm Width and height of label in mm, ie.
--paper-size mm mm Width and height of the paper in mm, ie. 210 297 for A4
paper portrait
--template-descriptor FILE
Path to JSON file containing descriptor of template
-h, --help display a help message
More detailed reference will be added in future.
Related examples
In CLI examples chapter, following examples show usage of the lablie tile
command:
lablie instance
command
The command instance
creates SVG document containing instantiated template with provided data.
Reference
Output of the lablie instance --help
:
Usage: lablie instance [OPTIONS] SOURCE TARGET
Fill label template with instance data
SOURCE Path of a SVG file containing a label
TARGET Path of a SVG file which should be generated
--instance-json <instanceJsonFile>
Path to JSON file containing values for single instance
-h, --help display a help message
More detailed reference will be added in future.
Related examples
Examples will be added in future.
lablie project
command
TODO: add a brief information
Reference
Output of the lablie project --help
:
Usage: lablie project [OPTIONS] [PROJECT_FILE] [COMMAND]
Group command for project manipulation sub-commands
[PROJECT_FILE] File containing project configuration
-h, --help display a help message
Commands:
generate-makefile Generates makefile for project
More detailed reference will be added in future.
Related examples
Examples will be added in future.
CLI Examples
Summary of examples:
Example | Description |
---|---|
01-tile-label | Create SVG and PDF for print containing tiled label |
02-tile-label-with-instancing | Create SVG(s) and PDF(s) for print containing tiled label filled with data of corresponding instances (products) |
91-batch-instacing-using-shell | Create instanced SVG(s) and PDF(s) for print, in batch, using bash script. |
92-batch-instacing-using-makefile | Create instanced PDF(s) for print, in batch, using Makefile . Supports incremental builds, thanks to make functionality. |
Example 01: tile label
The example shows creation of portrait A4 document with labels with 100 width and 30mm height:
Assumptions:
lablie
is installed (if not, see README),inkscape
is installed,label.svg
is present in current working directory (download label.svg).
Then, by invoking following commands:
lablie tile --paper-size 210 297 \
--label-offset 5 13.5 \
--label-size 100 30 \
--label-delta 0 0 \
label.svg \
label-tiled.svg
inkscape --file=label-tiled.svg --without-gui --export-png=label-tiled.png
inkscape --file=label-tiled.svg --without-gui --export-pdf=label-tiled.pdf
Following result files should have been created:
label-tiled.svg
containing tiled label on specified paper,label-tiled.png
containinglabel-tiled.svg
converted to PNG,label-tiled.pdf
containinglabel-tiled.svg
converted to PDF.
Example 02: tile label with instancing
lablie
is installed (if not, see README),inkscape
is installed,label.svg
is present in current working directory (download label.svg),product_honey.json
is present in current working directory (download product_honey.json),product_oranges.json
is present in current working directory (download product_oranges.json).
Then, by invoking following commands:
lablie tile --paper-size 210 297 --label-offset 5 13.5 --label-size 100 30 --label-delta 0 0 label.svg --instance-json product_honey.json label-tiled-honey.svg
lablie tile --paper-size 210 297 --label-offset 5 13.5 --label-size 100 30 --label-delta 0 0 label.svg --instance-json product_oranges.json label-tiled-oranges.svg
inkscape --file=label-tiled-honey.svg --without-gui --export-pdf=label-tiled-honey.pdf
inkscape --file=label-tiled-oranges.svg --without-gui --export-pdf=label-tiled-oranges.pdf
Following result files should have been created:
label-tiled-honey.svg
containing tiled label withproduct_honey.json
instance data,label-tiled-oranges.svg
containing tiled label withproduct_oranges.json
instance data,label-tiled-honey.pdf
containinglabel-tiled-honey.svg
converted to PDF,label-tiled-oranges.pdf
containinglabel-tiled-oranges.svg
converted to PDF.
Example 91: batch instancing using shell script
lablie
is installed (if not, see README),inkscape
is installed,make_instances.sh
is present in current working directory (download make_instances.sh),label.svg
is present in current working directory (download label.svg),product_honey.json
is present in current working directory (download product_honey.json),product_oranges.json
is present in current working directory (download product_oranges.json).
Then, by invoking following commands:
./make_instances.sh
Following result files should have been created:
label-tiled-honey.svg
containing tiled label withproduct_honey.json
instance data,label-tiled-oranges.svg
containing tiled label withproduct_oranges.json
instance data,label-tiled-honey.pdf
containinglabel-tiled-honey.svg
converted to PDF,label-tiled-oranges.pdf
containinglabel-tiled-oranges.svg
converted to PDF.
Example 92: batch instancing using Makefile
lablie
is installed (if not, see README),inkscape
is installed,Makefile
is present in current working directory (download Makefile),label.svg
is present in current working directory (download label.svg),product_honey.json
is present in current working directory (download product_honey.json),product_oranges.json
is present in current working directory (download product_oranges.json).
Then, by invoking following commands:
make
Following result files should have been created:
output/product_honey.pdf
containing PDF with labels for honey product,output/product_oranges.pdf
containing PDF with labels for orange product.
For developers
Java library
Library's artifacts are published to maven central. The library can be downloaded with maven as dependency:
<dependency>
<groupId>org.kravemir.svg.labels</groupId>
<artifactId>lablie</artifactId>
<version>0.4.0</version>
</dependency>
With gradle:
compile group: 'org.kravemir.svg.labels', name: 'lablie', version: '0.4.0'
See more details at at search.maven.org, or at mvnrepository.com.
Javadoc
Javadocs can found at:
CI / CD
The SVG labels is built as docker image, and published on dockerhub.
Usage with GitLab Runner
Example of .gitlab-ci.yml
:
image: kravemir/lablie:0.4.0
# install custom fonts used in templates for correct PDF generation
# set locale for international characters
before_script:
- apk add ttf-dejavu ttf-liberation ttf-linux-libertine texmf-dist-fontsextra ghostscript-fonts
- mkdir -p ~/.fonts; ln -s /usr/share/texmf-dist/fonts/opentype/ ~/.fonts/
- fc-cache -v -f
- fc-list
- export LANG=en_US.UTF-8
- export LANGUAGE=en_US:en
- export LC_ALL=en_US.UTF-8
# artwork job generating outputs
artwork:
script:
- make
artifacts:
paths:
- output