3 # This file is part of Koha.
5 # Koha is free software; you can redistribute it and/or modify it under the
6 # terms of the GNU General Public License as published by the Free Software
7 # Foundation; either version 2 of the License, or (at your option) any later
10 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
11 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License along with
15 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
16 # Suite 330, Boston, MA 02111-1307 USA
25 use PDF::Reuse::Barcode;
30 $Text::Wrap::columns = 39;
31 $Text::Wrap::separator = "\n";
33 my $htdocs_path = C4::Context->config('intrahtdocs');
37 # get the printing settings
38 my $conf_data = get_label_options();
39 my @resultsloop = get_label_items();
40 my $barcodetype = $conf_data->{'barcodetype'};
41 my $printingtype = $conf_data->{'printingtype'};
42 my $guidebox = $conf_data->{'guidebox'};
43 my $startrow = $conf_data->{'startrow'};
45 # if none selected, then choose 'both'
46 if ( !$printingtype ) {
47 $printingtype = 'both';
50 # opus paper dims. in *millimeters*
51 # multiply values by '2.83465', to find their value in Postscript points.
62 # sheet dimensions in PS points.
66 my $top_text_margin = 20;
67 my $left_text_margin = 10;
68 my $label_height = 96;
69 my $spine_width = 210;
78 # setting up the pdf doc
79 #remove the file before write, for testing
80 #unlink "$htdocs_path/barcodes/new.pdf";
81 #prFile("$htdocs_path/barcodes/new.pdf");
82 #prLogDir("$htdocs_path/barcodes");
84 # fix, no longer writes to temp dir
85 prInitVars(); # To initiate ALL global variables and tables
87 print STDOUT "Content-Type: application/pdf \n\n";
90 prMbox( 0, 0, $pagewidth, $pageheight );
91 prFont('courier'); # Just setting a font
96 my $y_pos_initial = ( ( $pageheight - $top_margin ) - $label_height );
97 my $y_pos_initial_startrow =
98 ( ( $pageheight - $top_margin ) - ( $label_height * $startrow ) );
99 my $y_pos = $y_pos_initial_startrow;
101 my $page_break_count = $startrow;
102 my $codetype = 'Code39';
105 # commented out coz it was running into the side-feeds of the paper.
106 # drawbox( 0, 0 , $pagewidth, $pageheight );
113 foreach $item (@resultsloop) {
114 my $x_pos_spine_tmp = $x_pos_spine;
118 if ( $guidebox == 1 ) {
120 "COUNT1, PBREAKCNT=$page_break_count, y=$y_pos, labhght = $label_height";
121 drawbox( $x_pos_spine_tmp, $y_pos, $spine_width, $label_height );
124 #-----------------draw spine text
125 if ( $printingtype eq 'spine' || $printingtype eq 'both' ) {
127 #warn "PRINTTYPE = $printingtype";
129 # add your printable fields manually in here
130 my @fields = qw (itemtype dewey isbn classification);
131 my $vPos = ( $y_pos + ( $label_height - $top_text_margin ) );
132 my $hPos = ( $x_pos_spine_tmp + $left_text_margin );
133 foreach my $field (@fields) {
135 # if the display option for this field is selected in the DB,
136 # and the item record has some values for this field, display it.
137 if ( $conf_data->{"$field"} && $item->{"$field"} ) {
139 #warn "CONF_TYPE = $field";
142 $str = $item->{"$field"};
144 # strip out naughty existing nl/cr's
148 # chop the string up into _upto_ 12 chunks
149 # and seperate the chunks with newlines
151 $str = wrap( "", "", "$str" );
152 $str = wrap( "", "", "$str" );
154 # split the chunks between newline's, into an array
155 my @strings = split /\n/, $str;
157 # then loop for each string line
158 foreach my $str (@strings) {
160 warn "HPOS , VPOS $hPos, $vPos ";
161 prText( $hPos, $vPos, $str );
162 $vPos = $vPos - $line_spacer;
164 } # if field is valid
168 $x_pos_spine_tmp = ( $x_pos_spine_tmp + $spine_width + $colspace );
170 warn " $y_pos - $label_height - $rowspace";
171 $y_pos = ( $y_pos - $label_height - $rowspace );
172 warn " $y_pos - $label_height - $rowspace";
174 #-----------------draw spine text
176 # the gaylord labels have 8 rows per sheet, this pagebreaks after 8 rows
177 if ( $page_break_count == $label_rows ) {
179 $page_break_count = 0;
181 $y_pos = $y_pos_initial;
188 #print $cgi->redirect("/intranet-tmpl/barcodes/new.pdf");