Bugfix: Fixing issues with the patron card pdf rendering code
This patch fixes two bugs: 1. Correcting the text alignment alogrithms for center and right alignment 2. Changes a reference to layout to a copy of the layout to avoid performing operations on the layout. Signed-off-by: Galen Charlton <gmcharlt@gmail.com>
This commit is contained in:
parent
745ac87c20
commit
7b1a3d1ae8
|
|
@ -58,12 +58,12 @@ sub text_alignment {
|
|||
return $origin_llx, $Tw;
|
||||
}
|
||||
elsif ($alignment eq 'C') {
|
||||
my $center_margin = ($text_box_width / 2) + $text_llx;
|
||||
my $center_margin = ($text_box_width / 2) + ($origin_llx - $text_llx);
|
||||
$Tx = $center_margin - ($string_width / 2);
|
||||
return $Tx, $Tw;
|
||||
}
|
||||
elsif ($alignment eq 'R') {
|
||||
$Tx = ($text_box_width - $string_width) + ($text_llx / 2);
|
||||
$Tx = ($text_box_width - $string_width) + (($origin_llx - $text_llx) / 2);
|
||||
return $Tx, $Tw;
|
||||
}
|
||||
elsif ($alignment eq 'L') {
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ sub draw_text {
|
|||
my ($self, $pdf, %params) = @_;
|
||||
warn sprintf('No pdf object passed in.') and return -1 if !$pdf;
|
||||
my @card_text = ();
|
||||
my $text = $self->{'layout'}->{'text'};
|
||||
my $text = [@{$self->{'layout'}->{'text'}}]; # make a copy of the arrayref *not* simply a pointer
|
||||
return unless (ref($text) eq 'ARRAY'); # just in case there is not text
|
||||
while (scalar @$text) {
|
||||
my $line = shift @$text;
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ my $lower_left_y = 0;
|
|||
my $upper_right_x = $template->get_attr('page_width');
|
||||
my $upper_right_y = $template->get_attr('page_height');
|
||||
|
||||
$pdf->Compress(1);
|
||||
$pdf->Compress(1); # comment this out to debug pdf files, but be sure to uncomment it in production or you may be very sorry...
|
||||
$pdf->Mbox($lower_left_x, $lower_left_y, $upper_right_x, $upper_right_y);
|
||||
|
||||
my ($llx, $lly) = 0,0;
|
||||
|
|
|
|||
Loading…
Reference in New Issue