wkhtmltopdf / perl:HTTP标头&记录

我刚刚发现了wkhtmltopdf,我试图在perl CGI脚本中使用它来生成PDF。基本上,perl脚本编写HTML文件,通过system()调用wkhtmltopdf来创建pdf,然后下载pdf并删除临时文件。
open NNN, ">$path_to_files/${file}_pdf.html" or die "can't write file: $!";
print NNN $text;
close NNN;

my @pdfSettings = (
    "d:/very/long/path/wkhtmltopdf",
    "$path_to_files/${file}_pdf.html",
    "$path_to_files/$file.pdf"
    );

system(@pdfSettings);

open(DLFILE, '<', "$path_to_files/$file.pdf");
   print $q->header(
        -type=> 'application/x-download',
        -attachment => "$file.pdf",
        -filename => "$file.pdf",
        'Content-length' => -s "$path_to_files/$file.pdf",
);

binmode DLFILE;
print while <DLFILE>;
close (DLFILE);


unlink("$path_to_files/${file}_pdf.html");
unlink("$path_to_files/${file}.pdf");
这在我的本地服务器上工作正常。但是,当我将它上传到我的公共服务器时,它会创建pdf文件,然后死于“指定的CGI应用程序因为没有返回一组完整的HTTP头而行为不端”。 将“print $ q-> header”移动到system()调用之前会导致pdf通过文件顶部的wkhtmltopdf的控制台输出(“加载页面(1/6)”等)生成,所以我认为发生了什么事情是wkhtmltopdf向服务器发出无头信息并导致其失败。但我在wkhtmltopdf文档中找不到关闭控制台输出的任何选项,我无法找出一个perl方法来抑制/重定向该输出。 (是的,我知道WKHTMLTOPDF.pm,但是因为我的ActivePerl风格而无法安装它,我想尽可能避免切换。)     
已邀请:
如何通过q​​x或反引号而不是system()执行,并将输出重定向到NUL:?
qx("d:/very/long/path/wkhtmltopdf" "$path_to_files/${file}_pdf.html" "$path_to_files/$file.pdf" > NUL: 2> NUL:);
    

要回复问题请先登录注册