Why don't the images fully display when I convert HTML to PDF with Perl's HTML::HTMLDoc?
I need to create a PDF file from the HTML I have created usign rrdcgi. This page contains the details and graphs in PNG format. I have written the below code using Perl module HTML::HTMLDoc to create a PDF file using saved HTML file. The images are of size width 1048 and hight 266 but when creating a PDF file the images are not shown completly from the right side.
#!/usr/bin/perl
use strict;
use warnings;
use HTML::HTMLDoc;
my $filename = shift;
my $htmldoc = new HTML::HTMLDoc();
$htmldoc->set_input_file($filename);
$htmldoc->no_links()开发者_运维问答;
$htmldoc->landscape();
$htmldoc->set_jpeg_compression('50');
$htmldoc->best_image_quality();
$htmldoc->color_on();
$htmldoc->set_right_margin('1', 'mm');
$htmldoc->set_left_margin('1', 'mm');
$htmldoc->set_bodycolor('#FFFFFF');
$htmldoc->set_browserwidth('1000');
my $pdf = $htmldoc->generate_pdf();
$pdf->to_file('foo.pdf');
I need help on following items:
How do I display the complete image on page.
Any help with the Perl code would be really appreciated.
Have a look to HTML::HTMLDoc documentation:
set_browserwidth($width)
specifies the browser width in pixels. The browser width is used to scale images and pixel measurements when generating PostScript and PDF files. It does not affect the font size of text. The default browser width is 680 pixels which corresponds roughly to a 96 DPI display.
Please note that your images and table sizes are equal to or smaller than the browser width, or your output will overlap or truncate in places.
You said that images are 1048 width but you specified 1000 on browser width using:
$htmldoc->set_browserwidth('1000');
try to increase browserwidth parameter to fit your images.
精彩评论