Adding donation spam in the printed pdf.
This commit is contained in:
parent
4450ba7892
commit
1307566334
@ -16,6 +16,7 @@ use Mojo::UserAgent;
|
|||||||
|
|
||||||
use PDF::API2;
|
use PDF::API2;
|
||||||
use Path::Tiny;
|
use Path::Tiny;
|
||||||
|
use Encode qw/decode encode/;
|
||||||
|
|
||||||
has _db_all_printings => ( is => 'lazy', );
|
has _db_all_printings => ( is => 'lazy', );
|
||||||
has last_invalid_card => (
|
has last_invalid_card => (
|
||||||
@ -87,11 +88,17 @@ sub from_text ( $self, $text ) {
|
|||||||
return $promise;
|
return $promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub _create_new_page($self, $pdf) {
|
||||||
|
my $page = $pdf->page;
|
||||||
|
$page->size('A4');
|
||||||
|
return $page;
|
||||||
|
}
|
||||||
|
|
||||||
sub _generate_pdf ( $self, $cards, $images ) {
|
sub _generate_pdf ( $self, $cards, $images ) {
|
||||||
my $number_image = 0;
|
my $number_image = 0;
|
||||||
my $pdf = PDF::API2->new;
|
my $pdf = PDF::API2->new;
|
||||||
my $page = $pdf->page;
|
my $page = $self->_create_new_page($pdf);
|
||||||
$page->size('A4');
|
my @pages = $page;
|
||||||
my @rectangle = $page->size;
|
my @rectangle = $page->size;
|
||||||
my $width_paper = $rectangle[2];
|
my $width_paper = $rectangle[2];
|
||||||
my $height_paper = $rectangle[3];
|
my $height_paper = $rectangle[3];
|
||||||
@ -103,8 +110,8 @@ sub _generate_pdf ( $self, $cards, $images ) {
|
|||||||
for ( my $i = 0 ; $i < $card->{quantity} ; $i++ ) {
|
for ( my $i = 0 ; $i < $card->{quantity} ; $i++ ) {
|
||||||
if ( $number_image > 8 ) {
|
if ( $number_image > 8 ) {
|
||||||
$number_image = 0;
|
$number_image = 0;
|
||||||
$page = $pdf->page;
|
$page = $self->_create_new_page($pdf);
|
||||||
$page->size('A4');
|
push @pages, $page;
|
||||||
}
|
}
|
||||||
my $margin_bottom = 25;
|
my $margin_bottom = 25;
|
||||||
my $mtg_card_width = 6.35;
|
my $mtg_card_width = 6.35;
|
||||||
@ -133,6 +140,31 @@ sub _generate_pdf ( $self, $cards, $images ) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for my $page (@pages) {
|
||||||
|
my $font = $pdf->font('Courier');
|
||||||
|
my $content = $page->text;
|
||||||
|
$content->position(0, $height_paper - 5);
|
||||||
|
$content->font($font, 5);
|
||||||
|
$content->text(decode 'utf-8', "The price of a colour printed page in Spain is around 0.50€, "
|
||||||
|
. "your pdf has @{[scalar @pages]} pages, that would be "
|
||||||
|
. (sprintf "%.2f", scalar(@pages) * 0.50)."€, if you could donate a 20% "
|
||||||
|
. "of this amount to this bot more features could be");
|
||||||
|
|
||||||
|
$content = $page->text;
|
||||||
|
|
||||||
|
$content->position(0, $height_paper - 10);
|
||||||
|
$content->font($font, 5);
|
||||||
|
$content->text(decode 'utf-8', "developed and the developer would be "
|
||||||
|
. "very grateful. I encourage you to donate "
|
||||||
|
. (sprintf "%.2f", scalar(@pages) * 0.50 * 0.20)."€ and help this bot to offer the best "
|
||||||
|
. "it possibly can offer. This is the donations Paypal");
|
||||||
|
|
||||||
|
$content = $page->text;
|
||||||
|
|
||||||
|
$content->position(0, $height_paper - 15);
|
||||||
|
$content->font($font, 5);
|
||||||
|
$content->text("https://paypal.me/sergiotarxz. Thank you very much for your support!!");
|
||||||
|
}
|
||||||
return $pdf->to_string;
|
return $pdf->to_string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user