Answer the question
In order to leave comments, you need to log in
What is the correct way to pass text to PHP through stdin using popen()?
Trying to remove or change PDF metadata (author, title, etc.). I do it through the pdftk utility , and everything works fine. But the hitch happens in PHP. I want to implement such a simple algorithm without resorting to creating files on disk:
1. I get the PDF metadata and add them to an array: exec("pdftk $pdffile dump_data output", $result);
2. I change the metadata in the array in the way I need.
3. I'm trying to submit this metadata under the guise of a text file, in the same form in which I received them:
$sh = popen("pdftk $pdffile update_info - output $resultpdf", "w");
fwrite( $sh, implode(PHP_EOL, $result) );
pclose($sh);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question