3
我在Perl中使用Open2打印PDF,它将HTML模板打印出来,并将其打印到可通过按钮下载的PDF中。Perl可以使用CSS将图像打印到PDF中吗?
他们想要一个水印就可以了,所以我预览网页它看起来很棒上使用
<style>
body {
background-image: url("watermark.jpg");
background-repeat: no-repeat;
}
</style>
,但是当你把它下载到PDF消失。任何方式我可以将其添加到我的PDF?
PDF的代码生成以下
sub pdfGenerator {
my $data = shift;
my $file = "$OUTFILES/$data.html";
open(my $fileFH, '<', $file) or return "Can not find file\n";
my $processId = open2(\*POUT, \*PIN, qq(html2ps -U -f /home/dir/cgi-bin/dir2/html2psrc-label));
my @lines = <$fileFH>;
print PIN @lines;
close PIN;
my @psLines;
while (<POUT>)
{
chomp;
push(@psLines,$_);
}
waitpid $processId, 0;
$processId = open2(\*POUT, \*PIN, qq(ps2pdf -sPAPERSIZE=letter - -));
print PIN "$_\n" foreach(@psLines);
close PIN;
my @pdfLines;
while (<POUT>) {
chomp;
push(@pdfLines, $_);
}
waitpid $processId, 0;
print "Content-Type: application/pdf\n";
print "Content-Disposition: attachment; filename=pdfName.pdf\n\n";
print "$_\n" foreach(@pdfLines);
}
我试图改变文件html2ps的,我还没有得到任何东西。 我的代码如下
@html2ps
{
paper
{
type: letter;
}
}
BODY
{
font-family: Helvetica;
margin: 2em 1em 2em 70px;
font-family: Helvetica, sans-serif;
color: black;
background-image: url("/dir/images/watermark.jpg");
background-repeat: no-repeat;
}
@page
{
margin-left: .75in;
margin-right: .75in;
margin-top: 1in;
margin-bottom: 1in;
}
如果您使用'html2ps'从命令行生成PDF,它会显示水印吗? “html2ps”是否可以访问水印的路径? – choroba
这不是Perl的问题。 –