1 2 3 4 5 6 7 8 9 10 11
#!/usr/bin/perl use strict; use warnings; use diagnostics; use utf8; $source = "/root/source.html"; $destination = "/root/test.pdf"; system("xvfb-run --server-args='-screen 0, 1024x768x24' wkhtmltopdf $source $destination");
1 2 3 4 5 6 7 8 9 10
my @cmd = ( 'xvfb-run', "--server-args='-screen 0, 1024x768x24'", 'wkhtmltopdf' $source, $destination, ); system( @cmd ) == 0 or die "Command <<@cmd>> not successful: $!\n";
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
#!/usr/bin/perl use strict; use warnings; use CGI::Carp qw(fatalsToBrowser); use utf8; my $RootAndSubDir = $ENV{'SCRIPT_FILENAME'}; $RootAndSubDir =~ s-(.*?)\/index.pl-$1/-g; my $root = "$RootAndSubDir"; my $in = $root."source.html"; my $out = $root."test.pdf"; print "Content-type: text/html\n\n"; print "<h1>Generating PDF...</h1>"; unlink($out); my @cmd = ( $root."wkhtmltopdf", $in, $out ); print "<pre>"; system( @cmd ) == 0 or print "Command <<@cmd>> not successful: $!\n"; print "</pre>"; print qq|<br/><br/><a href="http://example.com/pdf/test.pdf" target ="_blank">download PDF</a>|;
2013-02-16T15:59:54 cbxk1xgda ich bisher keine elegante und einfach Lösung gefunden habe PDFs aus HTML-Files inkl. CSS zu erstellen ...