Documenting $printer and fixing QRCodes v1.0.3
This commit is contained in:
parent
dcf28b7c97
commit
d707010942
@ -32,6 +32,47 @@ has file_format => (
|
||||
my $tmp = Exd::FileFormat->new_tmp;
|
||||
$tmp->set_script(<<'EOF');
|
||||
sub ($exd, $printer) {
|
||||
|
||||
## DOCS
|
||||
### API
|
||||
# === $printer->qr('https://example.com');
|
||||
# Generates a QRcode for the especified url.
|
||||
#
|
||||
# === $printer->image($image);
|
||||
# Takes a gd image or file name and prints it
|
||||
# into the ticket or sticker.
|
||||
#
|
||||
# You should use the image gallery to copy
|
||||
# to clipboard the code to put inside
|
||||
# $printer->image(...);
|
||||
#
|
||||
# === $printer->print_text(['text', $gd_image], 30);
|
||||
# The first argument is a arrayref of gd images and strings
|
||||
# the text will be shown as expected, the images will
|
||||
# be shown as if they were emojies.
|
||||
#
|
||||
# The last argument is the font size.
|
||||
#
|
||||
# === $printer->print();
|
||||
# Sends the data to be printed to the configured device, this
|
||||
# should be the last thing you do in the ticket generation.
|
||||
#
|
||||
# It is not warranted to work multiple times.
|
||||
#
|
||||
# === $printer->print_n_lf( 3 );
|
||||
# Prints the specified number of line breaks.
|
||||
#
|
||||
# === $printer->font('Font name');
|
||||
# Selects a font to be used in $self->print_text
|
||||
# You should copy the contents of $printer->font(...)
|
||||
# using the font gallery.
|
||||
#
|
||||
### Other data
|
||||
#
|
||||
# Additionally you can use freely the following modules Pango, Cairo
|
||||
# and the whole set of Perl core modules plus GD and GD::Barcode::QRcode
|
||||
#
|
||||
## End of DOCS
|
||||
$printer->print_text(
|
||||
[
|
||||
'hola mundo'
|
||||
|
@ -11,6 +11,7 @@ use Encode qw/decode/;
|
||||
use Path::Tiny;
|
||||
use Pango;
|
||||
use Cairo;
|
||||
use GD::Barcode::QRcode;
|
||||
|
||||
use Exd::Utils::String;
|
||||
|
||||
@ -31,11 +32,9 @@ has current_image => ( is => 'rw', );
|
||||
sub qr( $self, $url ) {
|
||||
my $tmpdir = Path::Tiny->tempdir;
|
||||
my $image_file = $tmpdir->child('image.png');
|
||||
my $qrcode = Imager::QRCode->new( size => 8 );
|
||||
my $img = $qrcode->plot( $url, {} );
|
||||
$img->write( file => '' . $image_file ) or die $img->errstr;
|
||||
$self->image($image_file);
|
||||
$self->print_text( $url, 20 );
|
||||
my $qrcode = GD::Barcode::QRcode->new( $url, {ModuleSize => 8});
|
||||
$qrcode = $qrcode->plot(NoText => 0);
|
||||
$self->image($qrcode);
|
||||
}
|
||||
|
||||
sub image( $self, $image ) {
|
||||
|
@ -30,6 +30,11 @@
|
||||
|
||||
|
||||
<releases>
|
||||
<release version="v1.0.3" date="2024-11-03">
|
||||
<description>
|
||||
<p>Adding documentation</p>
|
||||
</description>
|
||||
</release>
|
||||
<release version="v1.0.2" date="2024-11-03">
|
||||
<description>
|
||||
<p>Using custom build system for Flatpak</p>
|
||||
@ -86,11 +91,11 @@
|
||||
</screenshot>
|
||||
<screenshot>
|
||||
<image>https://git.owlcode.tech/sergiotarxz/Exd/raw/commit/b58bd9f9460939ee3a3e5a8bd088cd22fd5fb53a/Screenshot%20from%202024-11-03%2012-35-24.png</image>
|
||||
<caption>Showing image gallery embedded in file with the option to copy code to use it from the printer script.</caption>
|
||||
<caption>Showing image gallery embedded in file.</caption>
|
||||
</screenshot>
|
||||
<screenshot>
|
||||
<image>https://git.owlcode.tech/sergiotarxz/Exd/raw/commit/b58bd9f9460939ee3a3e5a8bd088cd22fd5fb53a/Screenshot%20from%202024-11-03%2012-35-38.png</image>
|
||||
<caption>Showing font gallery embedded in file with the option to copy code to use it from the printer script.</caption>
|
||||
<caption>Showing font gallery embedded in file.</caption>
|
||||
</screenshot>
|
||||
</screenshots>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user