koha-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: Mason James
Subject: [Koha-cvs] koha/barcodes label-print-pdf.pl [rel_2_2]
Date: Wed, 26 Jul 2006 00:03:36 +0000

CVSROOT:        /sources/koha
Module name:    koha
Branch:         rel_2_2
Changes by:     Mason James <sushi>     06/07/26 00:03:36

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

Log message:
        added back existing text wrap, using fixed width font, still working on 
this...

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

Patches:
Index: label-print-pdf.pl
===================================================================
RCS file: /sources/koha/koha/barcodes/label-print-pdf.pl,v
retrieving revision 1.1.2.4
retrieving revision 1.1.2.5
diff -u -b -r1.1.2.4 -r1.1.2.5
--- label-print-pdf.pl  20 Jul 2006 18:32:24 -0000      1.1.2.4
+++ label-print-pdf.pl  26 Jul 2006 00:03:35 -0000      1.1.2.5
@@ -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/opus-import/intranet/modules';
+use C4::Context("/etc/koha-opus-import.conf");
 
 #use strict;
 use CGI;
@@ -43,20 +43,18 @@
 
 warn Dumper $conf_data;
 
-
 my $barcodetype  = $conf_data->{'barcodetype'};
 my $printingtype = $conf_data->{'printingtype'};
 my $guidebox  = $conf_data->{'guidebox'};
 my $startrow     = $conf_data->{'startrow'};
 
-if (!$printingtype) {
+if ( !$printingtype ) {
        $printingtype = 'both';
 }
 
 warn $printingtype;
 warn $guidebox;
 
-
 #warn Dumper @resultsloop;
 
 # dimensions of gaylord paper
@@ -128,7 +126,7 @@
 
 my $i2 = 1;
 foreach $item (@resultsloop) {
-    if ( $i2 == 1  && $guidebox  == 1) {
+    if ( $i2 == 1 && $guidebox == 1 ) {
         draw_boundaries(
             $x_pos_spine, $x_pos_circ1,  $x_pos_circ2, $y_pos,
             $spine_width, $label_height, $circ_width
@@ -151,7 +149,8 @@
         $conf_data->{'barcodetype'}, \$item );
     build_circ_barcode( $x_pos_circ2, $y_pos, $item->{'barcode'},
         $conf_data->{'barcodetype'}, \$item );
-}
+    }
+
 # added for xpdf compat. doesnt use type3 fonts., but increases filesize from 
20k to 200k
 # i think its embedding extra fonts in the pdf file.
 #      mode => 'graphic',
@@ -172,7 +171,6 @@
 }
 ############## end of loop
 
-
 prEnd();
 
 #----------------------------------------------------------------------------
@@ -181,6 +179,9 @@
 
 if ( $printingtype eq 'spine' || $printingtype eq 'both' ) {
 
+    my $font        = 'Courier';
+    my $text_height = 90;
+
     $file = "$htdocs_path/barcodes/new.pdf";
 
     my $pdf = new PDF::Report( File => $file );
@@ -201,11 +202,14 @@
     #my $y_pos = ( $y_pos_initial_startrow  );
     #warn "Y POS = $y_pos";
 
-    # now needed now we are using centerString().
-    #$pdf->setAlign('left');
+    $pdf->setAlign('left');
     
-    # SET THE FONT SIZE
+    # SET THE FONT SIZE AND TYPE
+    $pdf->setFont($font);
     $pdf->setSize(9);
+    $fontname = $pdf->getFont();
+    my $fontsize = $pdf->getSize();
+    warn "fontname $fontname $fontsize";
 
     my $page_break_count = $startrow;
 
@@ -220,51 +224,75 @@
 
     foreach $item (@resultsloop) {
 
-        #warn Dumper $item;
-        #warn "START Y_POS=$y_pos";
+        warn "START Y_POS=$y_pos";
+
         my $firstrow = 0;
 
-        $pdf->setAddTextPos( $start_text_pos, ( $y_pos - 20 ) )
-          ;                    # INIT START POS
+        $pdf->setAddTextPos( 36, ( $y_pos - 15 ) );    # INIT START POS
         ( $hPos, $vPos ) = $pdf->getAddTextPos();
+        ( $hPos, $vPos1 ) = $pdf->getAddTextPos();
 
-        my $hPosEnd = ( $hPos + $spine_label_text_with );    # 72
         if ( $conf_data->{'dewey'} && $item->{'dewey'} ) {
+
             ( $hPos, $vPos1 ) = $pdf->getAddTextPos();
-            $pdf->centerString( $hPos, $hPosEnd, $vPos, $item->{'dewey'} );
-            $vPos = $vPos - $vPosSpacer;
+            warn "DEWEY1: x=$hPos,up=$vPos $item->{'dewey'}\n";
+            $pdf->addText( $item->{'dewey'}, 10, 72, 90 );
+            ( $hPos, $vPos1 ) = $pdf->getAddTextPos();
+            warn "DEWEY2: x=$hPos,up=$vPos1\n";
+            $firstrow = 1;
         }
 
         if ( $conf_data->{'isbn'} && $item->{'isbn'} ) {
+            if ( $vPos1 == $vPos && $firstrow != 0 ) {
+                warn "VPOS -10";
+                $pdf->setAddTextPos( 36, ( $vPos - 15 ) );
+            }
+            else {
+                $pdf->setAddTextPos( 36, $vPos1 - 5 );    #add a space
+            }
+
+            ( $hPos, $vPos ) = $pdf->getAddTextPos();
+            warn "ISBN1: x=$hPos,up=$vPos $item->{'isbn'}\n";
+            $pdf->addText( $item->{'isbn'}, 10, 72, 90 );
             ( $hPos, $vPos1 ) = $pdf->getAddTextPos();
-            $pdf->centerString( $hPos, $hPosEnd, $vPos, $item->{'isbn'} );
-            $vPos = $vPos - $vPosSpacer;
+            warn "ISBN2: x=$hPos,up=$vPos1\n";
+            $firstrow = 1;
         }
 
         if ( $conf_data->{'class'} && $item->{'classification'} ) {
-            ( $hPos, $vPos1 ) = $pdf->getAddTextPos();
-            $pdf->centerString( $hPos, $hPosEnd, $vPos,
-                $item->{'classification'} );
-            $vPos = $vPos - $vPosSpacer;
+
+            if ( $vPos1 == $vPos && $firstrow != 0 ) {
+                warn "VPOS -10";
+                $pdf->setAddTextPos( 36, ( $vPos - 15 ) );
         }
-               if ( $conf_data->{'subclass'} && $item->{'subclass'} ) {
-            ( $hPos, $vPos1 ) = $pdf->getAddTextPos();
-            $pdf->centerString( $hPos, $hPosEnd, $vPos,
-                $item->{'subclass'} );
-            $vPos = $vPos - $vPosSpacer;
+            else {
+                $pdf->setAddTextPos( 36, $vPos1 - 5 );    #add a space
         }
-               if ( $conf_data->{'itemcallnumber'} && 
$item->{'itemcallnumber'} ) {
+
+            ( $hPos, $vPos ) = $pdf->getAddTextPos();
+            warn "CLASS1: x=$hPos,up=$vPos1 $item->{'classification'}\n";
+            $pdf->addText( $item->{'classification'}, 10, 72, 90 );
             ( $hPos, $vPos1 ) = $pdf->getAddTextPos();
-            $pdf->centerString( $hPos, $hPosEnd, $vPos,
-                $item->{'itemcallnumber'} );
-            $vPos = $vPos - $vPosSpacer;
+            warn "CLASS2: x=$hPos,up=$vPos1\n";
+            $firstrow = 1;
         }
 
-
         if ( $conf_data->{'itemtype'} && $item->{'itemtype'} ) {
+
+            if ( $vPos1 == $vPos && $firstrow != 0 ) {
+                warn "VPOS -10";
+                $pdf->setAddTextPos( 36, ( $vPos - 15 ) );
+            }
+            else {
+                $pdf->setAddTextPos( 36, $vPos1 - 5 );    #add a space
+            }
+
+            ( $hPos, $vPos ) = $pdf->getAddTextPos();
+            warn "ITYPE1: x=$hPos,up=$vPos $item->{'itemtype'}\n";
+            $pdf->addText( $item->{'itemtype'}, 10, 72, 90 );
             ( $hPos, $vPos1 ) = $pdf->getAddTextPos();
-            $pdf->centerString( $hPos, $hPosEnd, $vPos, $item->{'itemtype'} );
-            $vPos = $vPos - $vPosSpacer;
+            warn "ITYPE2: x=$hPos,up=$vPos1\n";
+            $firstrow = 1;
         }
 
         #$pdf->drawRect(
@@ -274,9 +302,8 @@
         #);
 
         $y_pos = ( $y_pos - $label_height );
-
-        #warn "END LOOP Y_POS =$y_pos";
-        #    warn "PAGECOUNT END LOOP=$page_break_count";
+        warn "END LOOP Y_POS =$y_pos";
+        warn "PAGECOUNT END LOOP=$page_break_count";
         if ( $page_break_count == 8 ) {
             $pagenumber++;
             $pdf->openpage($pagenumber);
@@ -289,8 +316,7 @@
 
         $page_break_count++;
         $i2++;
-
-        #warn "#----------------------------------\n";
+        warn "#----------------------------------\n";
 
     }
     $DB::single = 1;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]