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

Mason James szrj1m at yahoo.com
Fri Oct 6 03:50:18 CEST 2006


CVSROOT:	/sources/koha
Module name:	koha
Branch:		dev_week
Changes by:	Mason James <sushi>	06/10/06 01:50:18

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

Log message:
	now generates scaled barcodes as well as spines (only tested on Code39, COOP2of5, and Industrial2of5 so far)

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

Patches:
Index: label-print-pdf.pl
===================================================================
RCS file: /sources/koha/koha/barcodes/label-print-pdf.pl,v
retrieving revision 1.1.2.2.2.2
retrieving revision 1.1.2.2.2.3
diff -u -b -r1.1.2.2.2.2 -r1.1.2.2.2.3
--- label-print-pdf.pl	2 Oct 2006 22:01:39 -0000	1.1.2.2.2.2
+++ label-print-pdf.pl	6 Oct 2006 01:50:18 -0000	1.1.2.2.2.3
@@ -11,8 +11,8 @@
 
 # the reason for this goofyness, it that i couldnt find a single perl package that handled both barcodes and decent text placement.
 
-#use lib '/usr/local/hlt/intranet/modules';
-#use C4::Context("/etc/koha-hlt.conf");
+use lib '/usr/local/hlt/intranet/modules';
+use C4::Context("/etc/koha-hlt.conf");
 
 use strict;
 use CGI;
@@ -30,7 +30,6 @@
 
 use Data::Dumper;
 
-
 my $htdocs_path = C4::Context->config('intrahtdocs');
 my $cgi         = new CGI;
 my $spine_text  = "";
@@ -54,26 +53,24 @@
 warn $unitvalue;
 warn $units;
 
-
 my $tmpl_code    = $template->{'tmpl_code'};
 my $tmpl_desc    = $template->{'tmpl_desc'};
 
-my $page_height  = ($template->{'page_height'} * $unitvalue );
-my $page_width   = ($template->{'page_width'} * $unitvalue );
-my $label_height = ($template->{'label_height'} * $unitvalue );
-my $label_width  = ($template->{'label_width'} * $unitvalue );
-my $spine_width = ($template->{'label_width'} * $unitvalue );
-my $circ_width  = ($template->{'label_width'} * $unitvalue );
-my $top_margin  = ($template->{'topmargin'} * $unitvalue );
-my $left_margin = ($template->{'leftmargin'} * $unitvalue );
-my $colspace    = ($template->{'colgap'} * $unitvalue );
-my $rowspace    = ($template->{'rowgap'} * $unitvalue );
+my $page_height  = ( $template->{'page_height'} * $unitvalue );
+my $page_width   = ( $template->{'page_width'} * $unitvalue );
+my $label_height = ( $template->{'label_height'} * $unitvalue );
+my $label_width  = ( $template->{'label_width'} * $unitvalue );
+my $spine_width  = ( $template->{'label_width'} * $unitvalue );
+my $circ_width   = ( $template->{'label_width'} * $unitvalue );
+my $top_margin   = ( $template->{'topmargin'} * $unitvalue );
+my $left_margin  = ( $template->{'leftmargin'} * $unitvalue );
+my $colspace     = ( $template->{'colgap'} * $unitvalue );
+my $rowspace     = ( $template->{'rowgap'} * $unitvalue );
 
 my $label_cols  = $template->{'cols'};
 my $label_rows  = $template->{'rows'}; 
 
-my $text_wrap_cols = GetTextWrapCols($fontsize, $label_width);
-
+my $text_wrap_cols = GetTextWrapCols( $fontsize, $label_width );
 
 warn $label_cols, $label_rows;
 
@@ -97,7 +94,6 @@
 my $margin = $top_margin;
 my $left_text_margin = 3;
 
-
 my $str;
 
 #warn "STARTROW = $startrow\n";
@@ -118,85 +114,83 @@
 warn "$label_height, $label_width\n";
 warn "$page_height, $page_width\n";
 
+my ( $rowcount, $colcount, $x_pos, $y_pos, $rowtemp, $coltemp );
 
-my ($rowcount, $colcount, $x_pos, $y_pos, $rowtemp, $coltemp);
-
- if ($start_label eq 1) {
+if ( $start_label eq 1 ) {
 	$rowcount = 1;
 	$colcount = 1;
 	$x_pos    = $left_margin;
 	$y_pos = ( $page_height - $top_margin - $label_height );
 }
 
-
 else {
-	$rowcount = ceil($start_label / $label_cols);	
-	$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));
+    $rowcount = ceil( $start_label / $label_cols );
+    $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 "ROW COL $rowcount, $colcount";
 
-foreach $item (@resultsloop) {
+#my $barcodetype = 'Code39';
 
+foreach $item (@resultsloop) {
 
     warn "-----------------";
-	if ($guidebox){
-    	drawbox( $x_pos, $y_pos, $label_width, $label_height);
+    if ($guidebox) {
+        drawbox( $x_pos, $y_pos, $label_width, $label_height );
 	}
-	DrawSpineText( $y_pos,$label_height, $fontsize,
-   		$x_pos, $left_text_margin, $text_wrap_cols,
-		\$item, \$conf_data);
+
+    if ( $printingtype eq 'spine' || $printingtype eq 'both' ) {
+        if ($guidebox) {
+            drawbox( $x_pos, $y_pos, $label_width, $label_height );
+        }
+
+        DrawSpineText( $y_pos, $label_height, $fontsize, $x_pos,
+            $left_text_margin, $text_wrap_cols, \$item, \$conf_data );
+        CalcNextLabelPos();
+    }
+
+    if ( $printingtype eq 'barcode' || $printingtype eq 'both' ) {
+        if ($guidebox) {
+            drawbox( $x_pos, $y_pos, $label_width, $label_height );
+        }
+
+        DrawBarcode( $x_pos, $y_pos,  $label_height, $label_width, $item->{'barcode'}, $barcodetype );
+        CalcNextLabelPos();
+    }
+
+}    # end for item loop
+prEnd();
+
+print $cgi->redirect("/intranet-tmpl/barcodes/new.pdf");
+
+sub CalcNextLabelPos {
     if ( $colcount lt $label_cols ) {
-        warn "new col";
+#        warn "new col";
         $x_pos = ( $x_pos + $label_width + $colspace );
         $colcount++;
     }
+
     else {
         $x_pos = $left_margin;
         if ( $rowcount eq $label_rows ) {
-            warn "new page";
+#            warn "new page";
             prPage();
             $y_pos    = ( $page_height - $top_margin - $label_height );
             $rowcount = 1;
         }
         else {
-            warn "new row";
+#            warn "new row";
             $y_pos = ( $y_pos - $rowspace - $label_height );
             $rowcount++;
         }
         $colcount = 1;
     }
-
-
-
-
-}    # end for item loop
-prEnd();
-
-print $cgi->redirect("/intranet-tmpl/barcodes/new.pdf");
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+}
 





More information about the Koha-cvs mailing list