getter usage example
[Printer-Zebra.git] / pbm2ZPL.pl
index 967969b..4b8f02c 100755 (executable)
@@ -8,7 +8,7 @@ use Data::Dump qw(dump);
 
 my $compress = $ENV{COMPRESS} || 1;
 
-my $pnm_file = shift @ARGV || die "usage: $0 print.pnm";
+my $pnm_file = shift @ARGV || die "usage: $0 print.pnm > print.zpl\n";
 
 open(my $fh, '<', $pnm_file);
 my $p4 = <$fh>; chomp $p4;
@@ -37,7 +37,7 @@ print '^MD13'; # media darkness -30 .. 30 / XiIIIPlus 0..30/0.1 increments
 print '^JUS'; # configuration update F = factory default R = recall S = save
 print '^LRN'; # label reverse Y/N
 print '^CI0'; # change international font 0..255
-print '^XZ'; 
+print "^XZ\r\n";
 
 printf "~DG000.GRF,%d,%d,\r\n", $w / 8 * $h, $w / 8;
 
@@ -66,11 +66,12 @@ sub zpl_compress {
 foreach my $y ( 0 .. $h - 1 ) {
        my $line = substr( $bitmap, $y * ( $w / 8 ), $w / 8 );
        if ( $line eq $last_line ) {
-               print ":" && warn "# $y repeat previous line\n";
+               print ':';
+               warn "# $y repeat previous line\n";
        } else {
                my $hex = unpack('H*', $line);
                if ( $compress ) {
-#                      $last_line = $line;
+                       $last_line = $line;
                        $hex =~ s/0+$/,/  && warn "# $y fill 0 to right\n";
                        $hex =~ s/F+$/!/i && warn "# $y fill 1 to right\n";
                        $hex =~ s/((.)\2+)/zpl_compress($1)/egs;
@@ -87,9 +88,9 @@ print '^LS0'; # label shift -9999..9999
 printf '^FT%d,%d', 0, $h; # field typeset x,y graphic origin is bottom-left
 print '^XG000.GRF,1,1^FS'; # recall grapmic source/name,magnification_x,magnification_y
 print '^PQ1,0,1,Y'; # print quantity total,pause/cut,replicates,no_pause
-print '^XZ';
+print "^XZ\r\n";
 
 print '^XA';
 print '^ID000.GRF^FS'; # object delete
-print '^XZ';
+print "^XZ\r\n";