diff options
author | Solomon Peachy <pizza@shaftnet.org> | 2015-07-16 07:19:17 -0400 |
---|---|---|
committer | Solomon Peachy <pizza@shaftnet.org> | 2015-07-16 07:19:17 -0400 |
commit | 475f734e15e40d996a0b85d6d0c265b5c1e9c9c8 (patch) | |
tree | 0b609252157471215fcd75bdd7f3c3cf54b5120a | |
parent | a9349a131bfc980836964c2c6b5177152e8d8a91 (diff) | |
download | slp_misc-475f734e15e40d996a0b85d6d0c265b5c1e9c9c8.tar.gz slp_misc-475f734e15e40d996a0b85d6d0c265b5c1e9c9c8.tar.bz2 slp_misc-475f734e15e40d996a0b85d6d0c265b5c1e9c9c8.zip |
Mangle PPDs for DNP printers.
-rwxr-xr-x | dnp-mangleppd.pl | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/dnp-mangleppd.pl b/dnp-mangleppd.pl new file mode 100755 index 0000000..74364e5 --- /dev/null +++ b/dnp-mangleppd.pl @@ -0,0 +1,48 @@ +#!/usr/bin/perl -w + +# cups-genppd.5.2 -p /tmp -Z dnp-ds40 dnp-ds620 dnp-ds80 dnp-dsrx1 +# for x in /tmp/*ppd ; do perl dnp-mangleppd.pl $x ; done + +my ($ppd, %sizes); + +$ppd = shift(@ARGV); + +open FILE, "<$ppd" || die ("can't open file"); + +while(<FILE>) { + if ($_ =~ "/\*PageSize (.*)\/(.*):.*/") { + $sizes{$1} = $2; + } +} + +close FILE; + +foreach my $key (keys(%sizes)) { + open FILE, "<$ppd" || die ("can't open file $ppd"); + + my $out = $ppd; + $out =~ s/.*stp-dnp-(.*)\.5\.2\.ppd/$1/; + $out =~ tr/a-z/A-Z/; + $out =~ s/DSRX1/RX1/; + + $sizes{"$key"} =~ s/(.*)\*(.*)/$1_x$2/; + $sizes{"$key"} =~ s/(.*)\+(.*)/$1_$2/; + + print "--> $key = $sizes{$key}\n"; + + open FILE2, ">$out-$sizes{$key}.ppd"; + + while(<FILE>) { + s/\*DefaultPageSize: .*/*DefaultPageSize: $key/; + s/\*DefaultPageRegion: .*/*DefaultPageRegion: $key/; + s/\*DefaultImageableArea: .*/*DefaultImageableArea: $key/; + s/\*DefaultPaperDimension: .*/*DefaultPaperDimension: $key/; + s/\*DefaultStpColorCorrection: .*/*DefaultStpColorCorrection: Uncorrected/; + s/\*DefaultStpColorPrecision: .*/*DefaultStpColorPrecision: Best/; + + print FILE2 "$_"; + } + + close FILE; + close FILE2; +} |