php - pdftk Error: Failed to open PDF file: -
i using pdftk
library extract form fields pdf .everything running fine except 1 issue got pdf file pdf file link. causes error given bellow
error: failed open pdf file: http://www.uscis.gov/sites/default/files/files/form/i-9.pdf done. input errors, no output created.
command
root@ri8-ms-7788:/home/ri-8# pdftk http://192.168.1.43/form/i-9.pdf dump_data_fields
the same command working other forms .
attempt1
i have tried encrypt pdf unsafe version produce same error . here command
pdftk http://192.168.1.43/forms/i-9.pdf input_pw foopass output /var/www/forms/un-i-9.pdf
update
this full function handle
public function formanalysis($pdfname) { $pdffile=yii::app()->getbaseurl(true).'/uploads/forms/'.$pdfname; exec("pdftk ".$pdffile." dump_data_fields 2>&1", $output,$retval); //got error pdf if these secure if(strpos($output[0],'error') !== false) { $unsafepdf=yii::getpathofalias('webroot').'/uploads/forms/un-'.$pdfname; //echo "pdftk ".$pdffile." input_pw foopass output ".$unsafepdf; exec("pdftk ".$pdffile." input_pw foopass output ".$unsafepdf); exec("pdftk ".$unsafepdf." dump_data_fields 2>&1", $outputunsafe,$retval); return $outputunsafe ; //$response=array('0'=>'error','error'=>$output[0]); //return $response; } //if (strpos($output[0],'error') !== false){ echo "error run" ; } // option handle error return $output; }
this may little trick solution should work . @bruno said encrypted file . should decrypt before use pdftk
. found way decrypt qpdf
free opem source library decrypt pdf, remove owner , user passwords etc , many more. can find here qpdf. install on system . , run command
qpdf --decrypt input.pdf output.pdf
then use output file in pdftk
command . should work .
Comments
Post a Comment