X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=labels%2Flabel-print-pdf.pl;h=51fefe1281f84188790d5cb26493aee962916942;hb=refs%2Ftags%2Fv3.00.04_fixed;hp=d21c19384ff386112515fd36ebb5ae65e66d3aa5;hpb=2a26033f951b2ef3e1622b85a6d17b0e328e071e;p=koha.git diff --git a/labels/label-print-pdf.pl b/labels/label-print-pdf.pl index d21c19384f..51fefe1281 100755 --- a/labels/label-print-pdf.pl +++ b/labels/label-print-pdf.pl @@ -1,6 +1,7 @@ #!/usr/bin/perl use strict; +use warnings; use CGI; use C4::Labels; use C4::Auth; @@ -13,7 +14,6 @@ use PDF::Reuse; use PDF::Reuse::Barcode; use POSIX; use Data::Dumper; -#use Smart::Comments; my $DEBUG = 0; my $DEBUG_LPT = 0; @@ -24,8 +24,6 @@ print $cgi->header( -type => 'application/pdf', -attachment => 'barcode.pdf' ); my $spine_text = ""; -#warn "label-print-pdf ***"; - # get the printing settings my $template = GetActiveLabelTemplate(); my $conf_data = get_label_options(); @@ -34,8 +32,7 @@ my $profile = GetAssociatedProfile($template->{'tmpl_id'}); my $batch_id = $cgi->param('batch_id'); my @resultsloop; -#$DB::single = 1; - +my $batch_type = $conf_data->{'type'}; my $barcodetype = $conf_data->{'barcodetype'}; my $printingtype = $conf_data->{'printingtype'}; my $guidebox = $conf_data->{'guidebox'}; @@ -109,11 +106,19 @@ my $lowerLeftY = 0; my $upperRightX = $page_width; my $upperRightY = $page_height; -prMbox( $lowerLeftX, $lowerLeftY, $upperRightX, $upperRightY ); +warn "Active profile: " . ($profile->{prof_id} || "None") if $DEBUG; -#warn "STARTROW = $startrow\n"; +#### PRINT PRELIMINARY DATA #### +print $cgi->header( -type => 'application/pdf', -attachment => 'barcode.pdf' ); + # Don't print header until very last possible moment + # That way if error or die occurs, fatals_to_browser will still work. + # After we print this header, there is no way back to HTML. All we can do is deliver PDF. +prInitVars(); +$| = 1; +prFile(); # No args means to STDOUT +prCompress(1); # turn on zip compression which dramatically reduces file size +prMbox( $lowerLeftX, $lowerLeftY, $upperRightX, $upperRightY ); -#my $page_break_count = $startrow; my $codetype; # = 'Code39'; #do page border @@ -154,11 +159,8 @@ if ( $DEBUG && $profile->{'prof_id'} ) { warn "No profile associated so no adjustment applied."; } -my $item; my ( $i, $i2 ); # loop counters -# big row loop - #warn " $lowerLeftX, $lowerLeftY, $upperRightX, $upperRightY"; #warn "$label_rows, $label_cols\n"; #warn "$label_height, $label_width\n"; @@ -174,35 +176,22 @@ if ( $start_label eq 1 ) { } else { - - #eval { $rowcount = ceil( $start_label / $label_cols ); - - #} ; - #$rowcount = 1 if $@; - $colcount = ( $start_label - ( ( $rowcount - 1 ) * $label_cols ) ); - $x_pos = $left_margin + ( $label_width * ( $colcount - 1 ) ) + ( $colspace * ( $colcount - 1 ) ); - $y_pos = $page_height - $top_margin - ( $label_height * $rowcount ) - ( $rowspace * ( $rowcount - 1 ) ); - warn "Start label specified: $start_label Beginning in row $rowcount, column $colcount" if $DEBUG; warn "X position = $x_pos Y position = $y_pos" if $DEBUG; warn "Rowspace = $rowspace Label height = $label_height" if $DEBUG; } -#warn "ROW COL $rowcount, $colcount"; - -#my $barcodetype; # = 'Code39'; - # # main foreach loop # -foreach $item (@resultsloop) { +foreach my $item (@resultsloop) { warn "Label parameters: xpos=$x_pos, ypos=$y_pos, lblwid=$label_width, lblhig=$label_height" if $DEBUG; if ( $printingtype eq 'BAR' ) { drawbox( $x_pos, $y_pos, $label_width, $label_height ) if $guidebox; @@ -221,7 +210,7 @@ foreach $item (@resultsloop) { DrawBarcode( $x_pos, $barcode_y, $barcode_height, $label_width, $item->{'barcode'}, $barcodetype ); DrawSpineText( $x_pos, $y_pos, $label_height, $label_width, $fontname, $fontsize, - $left_text_margin, $text_wrap_cols, \$item, \$conf_data ); + $left_text_margin, $text_wrap_cols, \$item, \$conf_data, $printingtype ); CalcNextLabelPos(); @@ -232,7 +221,7 @@ foreach $item (@resultsloop) { DrawBarcode( $x_pos, $y_pos, $barcode_height, $label_width, $item->{'barcode'}, $barcodetype ); DrawSpineText( $x_pos, $y_pos, $label_height, $label_width, $fontname, $fontsize, - $left_text_margin, $text_wrap_cols, \$item, \$conf_data ); + $left_text_margin, $text_wrap_cols, \$item, \$conf_data, $printingtype ); CalcNextLabelPos(); } @@ -244,7 +233,7 @@ foreach $item (@resultsloop) { CalcNextLabelPos(); drawbox( $x_pos, $y_pos, $label_width, $label_height ) if $guidebox; DrawSpineText( $x_pos, $y_pos, $label_height, $label_width, $fontname, $fontsize, - $left_text_margin, $text_wrap_cols, \$item, \$conf_data ); + $left_text_margin, $text_wrap_cols, \$item, \$conf_data, $printingtype ); CalcNextLabelPos(); } @@ -258,7 +247,6 @@ foreach $item (@resultsloop) { } elsif ( $printingtype eq 'PATCRD' ) { - my $borrowernumber = '3'; # Hardcoded for testing purposes... my $patron_data = $item; #FIXME: This needs to be paramatized and passed in from the user... @@ -268,7 +256,7 @@ foreach $item (@resultsloop) { $patron_data->{'branchname'} => ($fontsize + 3), }; - warn "Generating patron card for cardnumber $patron_data->{'cardnumber'}"; + $DEBUG and warn "Generating patron card for cardnumber $patron_data->{'cardnumber'}"; drawbox( $x_pos, $y_pos, $label_width, $label_height ) if $guidebox; my $barcode_height = $label_height / 2.75; #FIXME: Scaling barcode height; this needs to be a user parameter. @@ -278,25 +266,9 @@ foreach $item (@resultsloop) { $left_text_margin, $text_wrap_cols, $text, $printingtype ); CalcNextLabelPos(); } - - - - - - - - - - - } # end for item loop prEnd(); -# -# -# -# -# sub CalcNextLabelPos { if ( $colcount lt $label_cols ) {