+</%doc><%perl>
+
+no warnings qw(exec);
+
+use CommodsWeb;
+
+my $printable= printable($m);
+if ($printable =~ m/^pdf|^ps/) {
+ my $output;
+ my $got= $m->call_self(\$output);
+ if ($got) {
+ my @htargs= qw(htmldoc --continuous --gray --size 210x279mm
+ --left 1cm --right 1cm);
+ $printable =~ m/^[a-z]+/;
+ push @htargs, '-t',$&;
+ if ($printable =~ m/2$/) {
+ push @htargs, qw(--nup 2);
+ }
+ push @htargs, qw(-);
+
+ my $tmpfile= IO::File::new_tmpfile();
+ print $tmpfile $output or die $!;
+ $tmpfile->flush() or die $!;
+ seek $tmpfile,0,0 or die $!;
+ my $htmldoc= open HTMLDOC, "-|";
+ defined $htmldoc or die $!;
+ if (!$htmldoc) {
+ eval {
+ $ENV{'HTMLDOC_NOCGI'}=1;
+ open STDIN, '<&', $tmpfile or die $!;
+
+ exec @htargs;
+ die $!;
+ };
+ print STDERR "HTMLDOC FAILURE $@";
+ _exit(1);
+ }
+ my ($data,$read);
+ $r->content_type($printable eq 'pdf' ? 'application/pdf' :
+ 'application/postscript');
+ while ($read= read HTMLDOC,$data,32768) { print $data; }
+ defined $read or die $!;
+ $?=0; $!=0; close HTMLDOC or die "$! $? $output ";
+ return;
+ }
+}
+set_ctype_utf8();
+$r->content_type('text/html; charset=UTF-8');
+
+</%perl><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">