1

I am trying to run PDFtk using PHP exec. It worked fine with files that had physical locations. Is it possible to run exec if pdf data file is held in variable or does exec only work with files with physical locations? Below is my code. The first block worked but not the second one.

Working code:

<?php
    $output=null;
    $retval=null;
    exec('pdftk 12345.pdf cat 2 output abc.pdf', $output, $retval);
?>

Non-working code:

<?php
    $output=null;
    $retval=null;
    $pdf = file_get_contents('12345.pdf');
    exec('pdftk '.$pdf.' cat 2 output abc.pdf', $output, $retval);
?>
Sunderam Dubey
  • 1
  • 11
  • 20
  • 40
TWolfe
  • 7
  • 3

0 Answers0