X-Git-Url: http://git.rot13.org/?p=Printer-Zebra.git;a=blobdiff_plain;f=pbm2ZPL.pl;h=9652e2e7388fcc3a528096be051d045e5c64b51c;hp=5c095af110721f7bafdea3297e7ed04a7ef9b798;hb=0808a503457e90939e3a767770fb0815c55d6324;hpb=10b7a0774d32e9f960c1262db94d7eece16fd393 diff --git a/pbm2ZPL.pl b/pbm2ZPL.pl index 5c095af..9652e2e 100755 --- a/pbm2ZPL.pl +++ b/pbm2ZPL.pl @@ -13,8 +13,9 @@ my $pnm_file = shift @ARGV || die "usage: $0 print.pnm"; open(my $fh, '<', $pnm_file); my $p4 = <$fh>; chomp $p4; die "no P4 header in [$p4] from $pnm_file" unless $p4 eq 'P4'; -my $size = <$fh>; chomp $size; -my $size = <$fh>; chomp $size if $size =~ m/^#/; +my $size = <$fh>; +while ( $size =~ m/^#/ ) { $size = <$fh> }; # skip comments +chomp $size; my ( $w, $h ) = split(/ /,$size,$2); warn "WARNING: width of $pnm_file not 832 but $w !\n" if $w != 832; local $/ = undef; @@ -36,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; @@ -86,9 +87,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";