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
23 use C4::Interface::CGI::Output;
26 use PDF::Reuse::Barcode;
31 $Text::Wrap::columns = 39;
32 $Text::Wrap::separator = "\n";
34 my $htdocs_path = C4::Context->config('intrahtdocs');
38 # get the printing settings
39 my $conf_data = get_label_options();
40 my @resultsloop = get_label_items();
41 my $barcodetype = $conf_data->{'barcodetype'};
42 my $printingtype = $conf_data->{'printingtype'};
43 my $guidebox = $conf_data->{'guidebox'};
44 my $startrow = $conf_data->{'startrow'};
46 # if none selected, then choose 'both'
47 if ( !$printingtype ) {
48 $printingtype = 'both';
51 # opus paper dims. in *millimeters*
52 # multiply values by '2.83465', to find their value in Postscript points.
63 # sheet dimensions in PS points.
67 my $top_text_margin = 20;
68 my $left_text_margin = 10;
69 my $label_height = 96;
70 my $spine_width = 210;
79 # setting up the pdf doc
80 #remove the file before write, for testing
81 #unlink "$htdocs_path/barcodes/new.pdf";
82 #prFile("$htdocs_path/barcodes/new.pdf");
83 #prLogDir("$htdocs_path/barcodes");
85 # fix, no longer writes to temp dir
86 prInitVars(); # To initiate ALL global variables and tables
88 print STDOUT "Content-Type: application/pdf \n\n";
91 prMbox( 0, 0, $pagewidth, $pageheight );
92 prFont('courier'); # Just setting a font
97 my $y_pos_initial = ( ( $pageheight - $top_margin ) - $label_height );
98 my $y_pos_initial_startrow =
99 ( ( $pageheight - $top_margin ) - ( $label_height * $startrow ) );
100 my $y_pos = $y_pos_initial_startrow;
102 my $page_break_count = $startrow;
103 my $codetype = 'Code39';
106 # commented out coz it was running into the side-feeds of the paper.
107 # drawbox( 0, 0 , $pagewidth, $pageheight );
114 foreach $item (@resultsloop) {
115 my $x_pos_spine_tmp = $x_pos_spine;
119 if ( $guidebox == 1 ) {
121 "COUNT1, PBREAKCNT=$page_break_count, y=$y_pos, labhght = $label_height";
122 drawbox( $x_pos_spine_tmp, $y_pos, $spine_width, $label_height );
125 #-----------------draw spine text
126 if ( $printingtype eq 'spine' || $printingtype eq 'both' ) {
128 #warn "PRINTTYPE = $printingtype";
130 # add your printable fields manually in here
131 my @fields = qw (itemtype dewey isbn classification);
132 my $vPos = ( $y_pos + ( $label_height - $top_text_margin ) );
133 my $hPos = ( $x_pos_spine_tmp + $left_text_margin );
134 foreach my $field (@fields) {
136 # if the display option for this field is selected in the DB,
137 # and the item record has some values for this field, display it.
138 if ( $conf_data->{"$field"} && $item->{"$field"} ) {
140 #warn "CONF_TYPE = $field";
143 $str = $item->{"$field"};
145 # strip out naughty existing nl/cr's
149 # chop the string up into _upto_ 12 chunks
150 # and seperate the chunks with newlines
152 $str = wrap( "", "", "$str" );
153 $str = wrap( "", "", "$str" );
155 # split the chunks between newline's, into an array
156 my @strings = split /\n/, $str;
158 # then loop for each string line
159 foreach my $str (@strings) {
161 warn "HPOS , VPOS $hPos, $vPos ";
162 prText( $hPos, $vPos, $str );
163 $vPos = $vPos - $line_spacer;
165 } # if field is valid
169 $x_pos_spine_tmp = ( $x_pos_spine_tmp + $spine_width + $colspace );
171 warn " $y_pos - $label_height - $rowspace";
172 $y_pos = ( $y_pos - $label_height - $rowspace );
173 warn " $y_pos - $label_height - $rowspace";
175 #-----------------draw spine text
177 # the gaylord labels have 8 rows per sheet, this pagebreaks after 8 rows
178 if ( $page_break_count == $label_rows ) {
180 $page_break_count = 0;
182 $y_pos = $y_pos_initial;
189 #print $cgi->redirect("/intranet-tmpl/barcodes/new.pdf");