|
Lines 24-30
use autouse 'Data::Dumper' => qw(Dumper);
Link Here
|
| 24 |
use Text::Wrap qw(wrap); |
24 |
use Text::Wrap qw(wrap); |
| 25 |
#use Font::TTFMetrics; |
25 |
#use Font::TTFMetrics; |
| 26 |
|
26 |
|
| 27 |
use C4::Creators::Lib qw(get_font_types); |
27 |
use C4::Creators::Lib qw(get_font_types get_unit_values); |
| 28 |
use C4::Creators::PDF qw(StrWidth); |
28 |
use C4::Creators::PDF qw(StrWidth); |
| 29 |
use C4::Patroncards::Lib qw(unpack_UTF8 text_alignment leading box get_borrower_attributes); |
29 |
use C4::Patroncards::Lib qw(unpack_UTF8 text_alignment leading box get_borrower_attributes); |
| 30 |
|
30 |
|
|
Lines 69-74
sub draw_barcode {
Link Here
|
| 69 |
sub draw_guide_box { |
69 |
sub draw_guide_box { |
| 70 |
my ($self, $pdf) = @_; |
70 |
my ($self, $pdf) = @_; |
| 71 |
warn sprintf('No pdf object passed in.') and return -1 if !$pdf; |
71 |
warn sprintf('No pdf object passed in.') and return -1 if !$pdf; |
|
|
72 |
|
| 72 |
my $obj_stream = "q\n"; # save the graphic state |
73 |
my $obj_stream = "q\n"; # save the graphic state |
| 73 |
$obj_stream .= "0.5 w\n"; # border line width |
74 |
$obj_stream .= "0.5 w\n"; # border line width |
| 74 |
$obj_stream .= "1.0 0.0 0.0 RG\n"; # border color red |
75 |
$obj_stream .= "1.0 0.0 0.0 RG\n"; # border color red |
|
Lines 79-84
sub draw_guide_box {
Link Here
|
| 79 |
$pdf->Add($obj_stream); |
80 |
$pdf->Add($obj_stream); |
| 80 |
} |
81 |
} |
| 81 |
|
82 |
|
|
|
83 |
sub draw_guide_grid { |
| 84 |
my ($self, $pdf) = @_; |
| 85 |
warn sprintf('No pdf object passed in.') and return -1 if !$pdf; |
| 86 |
|
| 87 |
# Set up the grid in user defied units |
| 88 |
my $units = get_unit_values(); |
| 89 |
my $unitvalue = 1; |
| 90 |
my $unitdesc = ''; |
| 91 |
foreach my $un (@$units){ |
| 92 |
if ($un->{'type'} eq $self->{'layout'}->{'units'}) { |
| 93 |
$unitvalue = $un->{'value'}; |
| 94 |
$unitdesc = $un->{'desc'}; |
| 95 |
} |
| 96 |
} |
| 97 |
|
| 98 |
my $obj_stream = "q\n"; # save the graphic state |
| 99 |
my $x = $self->{'llx'}; |
| 100 |
my $y = $self->{'lly'}; |
| 101 |
|
| 102 |
my $cnt = 0; |
| 103 |
for ( $x = $self->{'llx'}/$unitvalue; $x <= ($self->{'llx'} + $self->{'width'})/$unitvalue; $x++) { |
| 104 |
my $xx = $x*$unitvalue; |
| 105 |
my $yy = $y + $self->{'height'}; |
| 106 |
if ( ($cnt % 10) && ! ($cnt % 5) ) { |
| 107 |
$obj_stream .= "0.0 1.0 0.0 RG\n"; |
| 108 |
$obj_stream .= "0 w\n"; |
| 109 |
} elsif ( $cnt % 5 ) { |
| 110 |
$obj_stream .= "0.0 1.0 1.0 RG\n"; |
| 111 |
$obj_stream .= "0 w\n"; |
| 112 |
} else { |
| 113 |
$obj_stream .= "0.0 0.0 1.0 RG\n"; |
| 114 |
$obj_stream .= "0 w\n"; |
| 115 |
} |
| 116 |
$cnt ++; |
| 117 |
|
| 118 |
$obj_stream .= "$xx $y m\n"; |
| 119 |
$obj_stream .= "$xx $yy l\n"; |
| 120 |
|
| 121 |
$obj_stream .= "s\n"; |
| 122 |
} |
| 123 |
|
| 124 |
$x = $self->{'llx'}; |
| 125 |
$y = $self->{'lly'}; |
| 126 |
$cnt = 0; |
| 127 |
for ( $y = $self->{'lly'}/$unitvalue; $y <= ($self->{'lly'} + $self->{'height'})/$unitvalue; $y++) { |
| 128 |
|
| 129 |
my $xx = $x + $self->{'width'}; |
| 130 |
my $yy = $y*$unitvalue; |
| 131 |
|
| 132 |
if ( ($cnt % 10) && ! ($cnt % 5) ) { |
| 133 |
$obj_stream .= "0.0 1.0 0.0 RG\n"; |
| 134 |
$obj_stream .= "0 w\n"; |
| 135 |
} elsif ( $cnt % 5 ) { |
| 136 |
$obj_stream .= "0.0 1.0 1.0 RG\n"; |
| 137 |
$obj_stream .= "0 w\n"; |
| 138 |
} else { |
| 139 |
$obj_stream .= "0.0 0.0 1.0 RG\n"; |
| 140 |
$obj_stream .= "0 w\n"; |
| 141 |
} |
| 142 |
$cnt ++; |
| 143 |
|
| 144 |
$obj_stream .= "$x $yy m\n"; |
| 145 |
$obj_stream .= "$xx $yy l\n"; |
| 146 |
$obj_stream .= "s\n"; |
| 147 |
} |
| 148 |
|
| 149 |
$obj_stream .= "Q\n"; # restore the graphic state |
| 150 |
$pdf->Add($obj_stream); |
| 151 |
|
| 152 |
# Add info about units |
| 153 |
my $strbottom = "0/0 $unitdesc"; |
| 154 |
my $strtop = sprintf('%.2f', $self->{'width'}/$unitvalue) .'/'. sprintf('%.2f', $self->{'height'}/$unitvalue); |
| 155 |
my $font_size = 6; |
| 156 |
$pdf->Font( 'Courier' ); |
| 157 |
$pdf->FontSize( $font_size ); |
| 158 |
my $strtop_len = $pdf->StrWidth($strtop) * 1.5; |
| 159 |
$pdf->Text( $self->{'llx'} + 2, $self->{'lly'} + 2, "0/0 $unitdesc"); |
| 160 |
$pdf->Text( $self->{'llx'} + $self->{'width'} - $strtop_len , $self->{'lly'} + $self->{'height'} - $font_size , $strtop ); |
| 161 |
} |
| 162 |
|
| 163 |
|
| 82 |
sub draw_text { |
164 |
sub draw_text { |
| 83 |
my ($self, $pdf, %params) = @_; |
165 |
my ($self, $pdf, %params) = @_; |
| 84 |
warn sprintf('No pdf object passed in.') and return -1 if !$pdf; |
166 |
warn sprintf('No pdf object passed in.') and return -1 if !$pdf; |