Thread html to pdf (6 answers)
Opened by vayu at 2006-06-23 12:50

vayu
 2006-06-23 13:36
#67575 #67575
User since
2005-01-13
782 Artikel
BenutzerIn
[default_avatar]
hmm ...

hat jemand von euch schonmal damit gearbeitet?

ich hab jetzt 2 Wege probiert. zuerst habe ich htmldoc direkt per hand gestartet also die gui-version und damit das pdf erzeugt. das funktioniert prima , also wirklich gut (war überrascht).

aber mit dem Modul kommt nur eine beschädigte datei heraus.

hab mal probiert sämtliche einstellungen aus der GUI in mein script zu übernehmen, aber irgendwie tut das nicht.

Code: (dl )
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
#!/usr/bin/perl

use strict;
use warnings;

use HTML::HTMLDoc;

my $htmldoc = new HTML::HTMLDoc();

my $filename = $ARGV[0];

print $filename."\n";

#$htmldoc->set_html_content(qq~<html><body>A PDF file</body></html>~);
$htmldoc->set_input_file($filename); # alternative to use a present file from your fs
$htmldoc->set_output_format("pdf14");
$htmldoc->set_charset("iso-8859-1");
$htmldoc->set_compression(1);
$htmldoc->links();
$htmldoc->set_pagemode("document");
$htmldoc->set_browserwidth(680);
my $pdf = $htmldoc->generate_pdf();

$pdf->to_file('foo.pdf');

print $htmldoc->error();

View full thread html to pdf