Subject: | windows pdf writing bugs |
Date: | Mon, 14 Sep 2009 15:22:20 -0500 |
To: | bug-HTML-HTMLDoc [...] rt.cpan.org |
From: | Tyson Boellstorff <perlcat [...] windstream.net> |
This code works great on unix (FreeBSD):
{
my ($handle)=@_;
my $htmldoc = new HTML::HTMLDoc();
$htmldoc->set_input_file($handle->{'html.path'}[0]);
my $pdf = $htmldoc->generate_pdf();
$pdf->to_file($handle->{'pdf.path'}[0]);
return $handle;
}
In order to avoid writing broken files in windows,
{
my ($handle)=@_;
my $htmldoc = new HTML::HTMLDoc();
open FH, '>', $handle->{'pdf.path'}[0];
binmode FH;
$htmldoc->set_input_file($handle->{'html.path'}[0]);
my $pdf = $htmldoc->generate_pdf();
print FH $pdf->to_string();
close FH;
return $handle;
}
This writes the document as a pdf document including images, but no text.
This code also fails to write the text in the document:
{
my ($handle)=@_;
my $htmldoc = new HTML::HTMLDoc();
open FH, '>', $handle->{'pdf.path'}[0];
binmode FH;
$htmldoc->set_html_content(qq~<html><body>A PDF file</body></html>~);
my $pdf = $htmldoc->generate_pdf();
print FH $pdf->to_string();
close FH;
return $handle;
}
THis works every time, but defeats the purpose:
{
my ($handle)=@_;
my $err=qx(htmldoc --webpage -f $handle->{'html.path'}[0]
$handle->{'html.path'}[0]);
return $handle;
}
I've tried setting the font to arial with no change -- wondering if it's
environment, but I saw no fontpath settings to add to the HTML::HTMLDoc
objects. Anyway, having to set binmode on a windows pdf to write it seems
like a bug to me, but even if that gets fixed, I'd need to get the text to
print, or use Image::Magick to generate the whole document from scratch. I
have sample output if you want.
Thanks,
Tyson Boellstorff