From bb0b48dc2fd42cff83e8333e6c0d9d651c0d0fb9 Mon Sep 17 00:00:00 2001 From: Sergiotarxz Date: Thu, 23 May 2024 13:13:28 +0200 Subject: [PATCH] Fixing margin left. --- lib/TgMagicPdf/PdfBuilder.pm | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/TgMagicPdf/PdfBuilder.pm b/lib/TgMagicPdf/PdfBuilder.pm index ed36b9a..ad991ec 100644 --- a/lib/TgMagicPdf/PdfBuilder.pm +++ b/lib/TgMagicPdf/PdfBuilder.pm @@ -90,7 +90,8 @@ sub _generate_pdf ( $self, $cards, $images ) { my $page = $pdf->page; $page->size('A4'); my @rectangle = $page->size; - my $n_pixels_per_cm = $rectangle[2] / 21.0; + my $width_paper = $rectangle[2]; + my $n_pixels_per_cm = $width_paper / 21.0; for my $card (@$cards) { my $images_card = $images->{ $card->{scryfallId} }; for my $image_kind ( keys %$images_card ) { @@ -100,11 +101,15 @@ sub _generate_pdf ( $self, $cards, $images ) { $page = $pdf->page; $page->size('A4'); } - my $margin_left = 25; my $margin_bottom = 25; my $mtg_card_width = 6.35; my $mtg_card_height = 8.89; my $small_line_to_cut_better_size = 0.5; + my $margin_left = ( + $width_paper + - ($mtg_card_width * 3) + - ($small_line_to_cut_better_size * 2) + ) / 2; open my $fh, '<', \$images_card->{$image_kind}; my $image = $pdf->image( $fh, format => 'jpeg' ); my $page_position_x = $number_image % 3;