[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Koha-cvs] koha/barcodes label-printf-pdf.pl [dev_week]
From: |
Mason James |
Subject: |
[Koha-cvs] koha/barcodes label-printf-pdf.pl [dev_week] |
Date: |
Mon, 27 Aug 2007 02:23:28 +0000 |
CVSROOT: /sources/koha
Module name: koha
Branch: dev_week
Changes by: Mason James <sushi> 07/08/27 02:23:28
Added files:
barcodes : label-printf-pdf.pl
Log message:
1st add, hard-coded multi-label pdf generation script
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/barcodes/label-printf-pdf.pl?cvsroot=koha&only_with_tag=dev_week&rev=1.1.2.1
Patches:
Index: label-printf-pdf.pl
===================================================================
RCS file: label-printf-pdf.pl
diff -N label-printf-pdf.pl
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ label-printf-pdf.pl 27 Aug 2007 02:23:28 -0000 1.1.2.1
@@ -0,0 +1,194 @@
+#!/usr/bin/perl
+
+use strict;
+use CGI;
+use C4::Labels;
+use C4::Auth;
+use C4::Output;
+use C4::Interface::CGI::Output;
+use C4::Context;
+use HTML::Template;
+use PDF::Reuse;
+use PDF::Reuse::Barcode;
+use POSIX;
+
+
+use Smart::Comments;
+
+my $htdocs_path = C4::Context->config('intrahtdocs');
+my $cgi = new CGI;
+print $cgi->header( -type => 'application/pdf', -attachment => 'barcode.pdf' );
+
+my $spine_text = "";
+
+# get the printing settings
+my $template = GetActiveLabelTemplate();
+my $conf_data = get_label_options();
+
+my $batch_id = $cgi->param('batch_id');
+my @resultsloop = get_label_items($batch_id);
+
+my $barcodetype = $conf_data->{'barcodetype'};
+my $printingtype = $conf_data->{'printingtype'};
+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 $label_height = 40;
+my $label_width = 60;
+
+my $spine_width = 20;
+my $spine_height = 70;
+
+my $top_margin = 10;
+my $left_margin = 10;
+my $colspace = 10;
+my $rowspace = 10;
+
+my $label_cols = 2 ;
+my $label_rows = 2;
+
+my $text_wrap_cols = GetTextWrapCols( $fontsize, $label_width );
+
+#warn $label_cols, $label_rows;
+
+# set the paper size
+my $lowerLeftX = 0;
+my $lowerLeftY = 0;
+my $upperRightX = $page_width;
+my $upperRightY = $page_height;
+
+prInitVars();
+$| = 1;
+prFile();
+
+prMbox( $lowerLeftX, $lowerLeftY, $upperRightX, $upperRightY );
+
+# later feature, change the font-type and size?
+prFont('C'); # Just setting a font
+prFontSize($fontsize);
+
+my $margin = $top_margin;
+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
+
+# big row loop
+
+#warn " $lowerLeftX, $lowerLeftY, $upperRightX, $upperRightY";
+#warn "$label_rows, $label_cols\n";
+#warn "$label_height, $label_width\n";
+#warn "$page_height, $page_width\n";
+
+my ( $rowcount, $colcount, $x_pos, $y_pos, $rowtemp, $coltemp );
+
+
+ $start_label = 1 ; ## debug...................................
+my $block_height= 90;
+my $block_width = 90;
+
+if ( $start_label eq 1 ) {
+ $rowcount = 1;
+ $colcount = 1;
+ $x_pos = $left_margin;
+ $y_pos = ( $page_height - $top_margin - $block_height );
+}
+
+else {
+
+ eval {
+ $rowcount = ceil( $start_label / $label_cols );
+
+ } ;
+ #$rowcount = 1 if $@;
+
+ $colcount = ( $start_label - ( ( $rowcount - 1 ) * $label_cols ) );
+
+ $x_pos = $left_margin + ( $block_width * ( $colcount - 1 ) ) +
+ ( $colspace * ( $colcount - 1 ) );
+
+ $y_pos = $page_height - $top_margin - ( $block_height * $rowcount ) -
+ ( $rowspace * ( $rowcount - 1 ) );
+
+}
+
+# warn "ROW COL $rowcount, $colcount";
+
+
+#
+# main foreach loop
+#
+
+# $barcodetype = "CODE39MOD10";
+
+foreach $item (@resultsloop) {
+# 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, $y_pos, $block_width, $block_height, ) if $guidebox;
+ drawbox( $x_pos, $y_pos+20, $spine_width, $spine_height, ) if $guidebox;
+
+ drawbox( $x_pos+30, $y_pos+50, $label_width, $label_height, ) if $guidebox;
+ drawbox( $x_pos+30, $y_pos , $label_width, $label_height, ) if $guidebox;
+
+} # end for item loop
+prEnd();
+
+#
+#
+#
+#
+#
+sub CalcNextLabelPos {
+ if ( $colcount lt $label_cols ) {
+
+ # warn "new col";
+ $x_pos = ( $x_pos + $label_width + $colspace );
+ $colcount++;
+ }
+
+ else {
+ $x_pos = $left_margin;
+ if ( $rowcount eq $label_rows ) {
+
+ # warn "new page";
+ prPage();
+ $y_pos = ( $page_height - $top_margin - $label_height );
+ $rowcount = 1;
+ }
+ else {
+
+ # warn "new row";
+ $y_pos = ( $y_pos - $rowspace - $label_height );
+ $rowcount++;
+ }
+ $colcount = 1;
+ }
+}
+
- [Koha-cvs] koha/barcodes label-printf-pdf.pl [dev_week],
Mason James <=
- [Koha-cvs] koha/barcodes label-printf-pdf.pl [dev_week], Mason James, 2007/08/27
- [Koha-cvs] koha/barcodes label-printf-pdf.pl [dev_week], Mason James, 2007/08/27
- [Koha-cvs] koha/barcodes label-printf-pdf.pl [dev_week], Mason James, 2007/08/27
- [Koha-cvs] koha/barcodes label-printf-pdf.pl [dev_week], Mason James, 2007/08/27
- [Koha-cvs] koha/barcodes label-printf-pdf.pl [dev_week], Mason James, 2007/08/28