Saturday, January 29, 2011

convert html to pdf

#Add Module..
use PDF::FromHTML;
#Create object for that Module..
my $pdf = new PDF::FromHTML( encoding => 'utf-8' );
# Loading from a file..
$pdf->load_file('source.htm');

# Or from a scalar reference:
#$input = "<html><body>sample test<br><b>deiveegan</b></
body></html>";
# $pdf->load_file(\$input);

# Perform the actual conversion..
$pdf->convert(
Font => 'arial.ttf',
LineHeight => 18,
Landscape => 2,
);

# Write to a file:.
$pdf->write_file('Target.pdf');

# Or to a scalar reference:
# $pdf->write_file(\$output);

2 comments:

Anonymous said...

That actually is conversion from html to pdf (the opposite i the title).

Unknown said...
This comment has been removed by the author.