dongyi2083
2017-03-11 17:34
浏览 39

pdftk没有用PHP输出

I successfully installed pdftk on a VPS. It works fine when I run the commands in command line, but when I run the script on php it does not generate the pdf file. No errors anything. Has anyone had this same issue? When the script is run on php the fdf file is generated but not the pdf.

Here is the code sample i am using.

$fName = 'Ryan';
$lName = 'Kempt';
$dateNow = date('F jS, Y');

$fdf = '%FDF-1.2
1 0 obj<</FDF<< /Fields[
<</T(first_name)/V('.$fName.')>>
<</T(last_name)/V('.$lName.')>>
<</T(date)/V('.$dateNow.')>>
] >> >>
endobj
trailer
<</Root 1 0 R>>
%%EOF';

file_put_contents('test.fdf', $fdf);

$out = '';

exec("pdftk test.pdf fill_form test.fdf output filled.pdf flatten", "2>&1", $out);

when I run pdftk test.pdf fill_form test.fdf output filled.pdf flatten on the terminal the pdf file was generated.

after adding 2>&1 I get error Fatal error: Only variables can be passed by reference

  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

相关推荐 更多相似问题