From 201a220cbabd53adbe461330e84781befe549340 Mon Sep 17 00:00:00 2001 From: Sergiotarxz Date: Thu, 23 May 2024 16:12:59 +0200 Subject: [PATCH] Trying bigger cards in this trying times. --- lib/TgMagicPdf/PdfBuilder.pm | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/TgMagicPdf/PdfBuilder.pm b/lib/TgMagicPdf/PdfBuilder.pm index 4b49108..11bccae 100644 --- a/lib/TgMagicPdf/PdfBuilder.pm +++ b/lib/TgMagicPdf/PdfBuilder.pm @@ -91,7 +91,9 @@ sub _generate_pdf ( $self, $cards, $images ) { $page->size('A4'); my @rectangle = $page->size; my $width_paper = $rectangle[2]; - my $n_pixels_per_cm = $width_paper / 21.0; + my $height_paper = $rectangle[3]; + my $n_pixels_per_cm_width = $width_paper / 21.0; + my $n_pixels_per_cm_height = $height_paper / 29.7; for my $card (@$cards) { my $images_card = $images->{ $card->{scryfallId} }; for my $image_kind ( keys %$images_card ) { @@ -103,26 +105,26 @@ sub _generate_pdf ( $self, $cards, $images ) { } my $margin_bottom = 25; my $mtg_card_width = 6.35; - my $mtg_card_height = 8.89; + my $mtg_card_height = 9.15; my $small_line_to_cut_better_size = 0.5; open my $fh, '<', \$images_card->{$image_kind}; my $image = $pdf->image( $fh, format => 'jpeg' ); my $margin_left = ( $width_paper - - ( $n_pixels_per_cm * $mtg_card_width * 3 ) - + ( $n_pixels_per_cm_width * $mtg_card_width * 3 ) - ( $small_line_to_cut_better_size * 2 ) ) / 2; my $page_position_x = $number_image % 3; my $page_position_y = abs( int( $number_image / 3 ) - 2 ); $page->object( $image, $margin_left + - $page_position_x * $mtg_card_width * $n_pixels_per_cm + + $page_position_x * $mtg_card_width * $n_pixels_per_cm_width + $small_line_to_cut_better_size * $page_position_x, $margin_bottom + - $page_position_y * $mtg_card_height * $n_pixels_per_cm + + $page_position_y * $mtg_card_height * $n_pixels_per_cm_height + $small_line_to_cut_better_size * $page_position_y, - $n_pixels_per_cm * $mtg_card_width, - $n_pixels_per_cm * $mtg_card_height, + $n_pixels_per_cm_width * $mtg_card_width, + $n_pixels_per_cm_height * $mtg_card_height, ); $number_image++; }