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>
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') {
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;
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;