[Koha-cvs] koha/barcodes label-printf-pdf.pl [dev_week]

Mason James szrj1m at yahoo.com
Tue Aug 28 01:40:33 CEST 2007


CVSROOT:	/sources/koha
Module name:	koha
Branch:		dev_week
Changes by:	Mason James <sushi>	07/08/27 23:40:33

Modified files:
	barcodes       : label-printf-pdf.pl 

Log message:
	working page breaks

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/barcodes/label-printf-pdf.pl?cvsroot=koha&only_with_tag=dev_week&r1=1.1.2.3&r2=1.1.2.4

Patches:
Index: label-printf-pdf.pl
===================================================================
RCS file: /sources/koha/koha/barcodes/Attic/label-printf-pdf.pl,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -u -b -r1.1.2.3 -r1.1.2.4
--- label-printf-pdf.pl	27 Aug 2007 22:52:35 -0000	1.1.2.3
+++ label-printf-pdf.pl	27 Aug 2007 23:40:32 -0000	1.1.2.4
@@ -12,7 +12,6 @@
 use PDF::Reuse::Barcode;
 use POSIX;
 
-
 use Smart::Comments;
 
 my $htdocs_path = C4::Context->config('intrahtdocs');
@@ -33,18 +32,19 @@
 my $guidebox     = $conf_data->{'guidebox'};
 my $start_label  = $conf_data->{'startlabel'};
 
-
 my $fontsize     = $template->{'fontsize'};
 my $units        = $template->{'units'};
 
-
 my $unitvalue = GetUnitsValue($units);
 
 my $tmpl_code = $template->{'tmpl_code'};
 my $tmpl_desc = $template->{'tmpl_desc'};
 
-my $page_height  = 200;
-my $page_width   = 200;
+my $page_height = 510;
+my $page_width  = 210;
+
+my $block_height = 90;
+my $block_width  = 90;
 
 my $label_height = 40;
 my $label_width = 60;
@@ -57,11 +57,9 @@
 my $colspace     = 10;
 my $rowspace     = 10;
 
-my $label_cols = 2 ;
-my $label_rows = 2;
+my $block_cols = 2;
+my $block_rows = 5;
 
-#my $text_wrap_label = GetTextWrapCols( $fontsize, $label_width );
-#my $text_wrap_spine = GetTextWrapCols( $fontsize, $spine_width );
 
 #warn $label_cols, $label_rows;
 
@@ -85,14 +83,6 @@
 my $left_text_margin = 3;
 my $str;
 
-#warn "STARTROW = $startrow\n";
-
-#my $page_break_count = $startrow;
-#my $codetype = 'Code39';
-
-#do page border
-#drawbox( $lowerLeftX, $lowerLeftY, $upperRightX, $upperRightY );
-
 my $item;
 my ( $i, $i2 );    # loop counters
 
@@ -105,10 +95,7 @@
 
 my ( $rowcount, $colcount, $x_pos, $y_pos, $rowtemp, $coltemp );
 
-
- $start_label =  1 ; ## debug...................................
-my $block_height= 90;
-my $block_width = 90;
+$start_label = 1;    ## debug...................................
 
 if ( $start_label eq 1 ) {
     $rowcount = 1;
@@ -119,15 +106,15 @@
 
 else {
 
-    eval {
-    $rowcount = ceil( $start_label / $label_cols );
+    #eval {
+    $rowcount = ceil( $start_label / $block_cols );
 
-    } ;
+    #} ;
     #$rowcount = 1 if $@;
 
-    $colcount = ( $start_label - ( ( $rowcount - 1 ) * $label_cols ) );
+    $colcount = ( $start_label - ( ( $rowcount - 1 ) * $block_cols ) );
 
-    $x_pos = $left_margin + ( $block_width * ( $colcount - 1 ) ) +
+    $x_pos = $left_margin + ( $label_width * ( $colcount - 1 ) ) + 
       ( $colspace * ( $colcount - 1 ) );
 
     $y_pos = $page_height - $top_margin - ( $block_height * $rowcount ) -
@@ -135,9 +122,6 @@
 
 }
 
-# warn "ROW COL $rowcount, $colcount";
-
-
 #
 #    main foreach loop
 #
@@ -149,70 +133,80 @@
 foreach $item (@resultsloop) {
     my $barcode = $item->{'barcode'};
  $item->{callnumber} = 'BT 380.2 W54';
-my @callnumber = split (/ /, $item->{callnumber});
-
-my @spine_fields = ($item->{ccode},
-        $callnumber[0],
-        $callnumber[1],
-        $callnumber[2],
-        $item->{copyrightdate} );
-
-
-
-
+    my @callnumber = split( / /, $item->{callnumber} );
 
-my @circ_fields = ( $item->{ccode},
- $callnumber[0],
-        $callnumber[1],
-        $callnumber[2],
-        $item->{copyrightdate} );
+    my @spine_fields = (
+        $item->{ccode}, $callnumber[0], $callnumber[1],
+        $callnumber[2], $item->{copyrightdate}
+    );
 
-my @circ2_fields = ( 
-  $item->{author},
-  $item->{title});
+    my @circ_fields = (
+        $item->{ccode}, $callnumber[0], $callnumber[1],
+        $callnumber[2], $item->{copyrightdate}
+    );
 
-my @circ_barcode = ($item->{'barcode'} );
+    my @circ2_fields = ( $item->{author}, $item->{title} );
 
+    my @circ_barcode = ( $item->{'barcode'} );
 
-my $fontsize= 3;
+    my $fontsize = 3;
 
-#    warn "$x_pos, $y_pos, $label_width, $label_height";
+    #    warn "$x_pos, $y_pos, $label_width, $label_height";
     my $barcode = $item->{'barcode'};
-#  drawbox( $x_pos+30, $y_pos-10, $label_width, $label_height ) if $guidebox;
-#  drawbox( $x_pos+10, $y_pos, 100, 100 ) if $guidebox;
 
+   #  drawbox( $x_pos+30, $y_pos-10, $label_width, $label_height ) if $guidebox;
+   #  drawbox( $x_pos+10, $y_pos, 100, 100 ) if $guidebox;
 
   drawbox( $x_pos, $y_pos, $block_width,  $block_height,  ) if $guidebox;
-  drawbox( $x_pos, $y_pos+20, $spine_width,  $spine_height,  ) if $guidebox;
+    drawbox( $x_pos, $y_pos + 20, $spine_width, $spine_height, ) if $guidebox;
 
-    draw_text_block_manual2( $x_pos, $y_pos+20, $spine_width, $spine_height, $fontsize, '',     $gutter,    'l', @spine_fields);
+    draw_text_block_manual2(
+        $x_pos,    $y_pos + 20, $spine_width, $spine_height,
+        $fontsize, '',          $gutter,      'l',
+        @spine_fields
+    );
+
+    drawbox( $x_pos + 30, $y_pos + 50, $label_width, $label_height, )
+      if $guidebox;
+    draw_text_block_manual2(
+        $x_pos + 30, $y_pos + 50, $label_width, $label_height,
+        $fontsize,   '',          $gutter,      'r',
+        @circ_barcode
+    );
+
+    draw_text_block_manual2(
+        $x_pos + 30, $y_pos + 50, $label_width, $label_height,
+        $fontsize,   '',          $gutter,,
+        '',          @circ_fields
+    );
+
+    draw_text_block_manual2(
+        $x_pos + $spine_width + 30,
+        $y_pos + 50,
+        $label_width, $label_height, $fontsize, 2, $gutter, 'l', @circ2_fields
+    );
+
+    drawbox( $x_pos + 30, $y_pos, $label_width, $label_height, ) if $guidebox;
+    draw_text_block_manual2(
+        $x_pos + 30, $y_pos, $label_width, $label_height,
+        $fontsize,   '',     $gutter,      'r',
+        @circ_barcode
+    );
+
+    draw_text_block_manual2(
+        $x_pos + 30, $y_pos, $label_width, $label_height,
+        $fontsize,   '',     $gutter,,
+        '',          @circ_fields
+    );
+
+    draw_text_block_manual2( $x_pos + $spine_width + 30,
+        $y_pos, $label_width, $label_height, $fontsize, 2, $gutter, 'l',
+        @circ2_fields );
 
+    #calc_next_block_position();
+ CalcNextLabelPos();
 
- drawbox(     $x_pos+30, $y_pos+50, $label_width,  $label_height,  ) if $guidebox;
-    draw_text_block_manual2( $x_pos+30, $y_pos+50, $label_width, $label_height, $fontsize,  '',    $gutter, 'r', @circ_barcode);
-
-    draw_text_block_manual2( $x_pos+30, $y_pos+50, $label_width, $label_height, $fontsize,  '',    $gutter, , '' , @circ_fields);
-
-    draw_text_block_manual2( $x_pos+$spine_width+30, $y_pos+50, $label_width, $label_height, $fontsize,  2,    $gutter,  'l' , @circ2_fields);
-
-
- 
-  
-  drawbox( $x_pos+30, $y_pos , $label_width,  $label_height,  ) if $guidebox;
-    draw_text_block_manual2( $x_pos+30, $y_pos, $label_width, $label_height, $fontsize,  '',    $gutter, 'r', @circ_barcode);
-
-    draw_text_block_manual2( $x_pos+30, $y_pos, $label_width, $label_height, $fontsize,  '',    $gutter, , '' , @circ_fields);
-
-    draw_text_block_manual2( $x_pos+$spine_width+30, $y_pos, $label_width, $label_height, $fontsize,  2,    $gutter,  'l' , @circ2_fields);
-
-
-
-  
-
-
-#calc_next_block_position();
-
-last;
+#    last;
 }    # end for item loop
 prEnd();
 
@@ -222,26 +216,26 @@
 #
 #
 sub CalcNextLabelPos {
-    if ( $colcount lt $label_cols ) {
+    if ( $colcount lt $block_cols ) {
 
         #        warn "new col";
-        $x_pos = ( $x_pos + $label_width + $colspace );
+        $x_pos = ( $x_pos + $block_width + $colspace );
         $colcount++;
     }
 
     else {
         $x_pos = $left_margin;
-        if ( $rowcount eq $label_rows ) {
+        if ( $rowcount eq $block_rows ) {
 
             #            warn "new page";
             prPage();
-            $y_pos    = ( $page_height - $top_margin - $label_height );
+            $y_pos    = ( $page_height - $top_margin - $block_height );
             $rowcount = 1;
         }
         else {
 
             #            warn "new row";
-            $y_pos = ( $y_pos - $rowspace - $label_height );
+            $y_pos = ( $y_pos - $rowspace - $block_height );
             $rowcount++;
         }
         $colcount = 1;





More information about the Koha-cvs mailing list