使用交互式pdf将数据从iframe发送到php

时间:2013-07-26 18:27:58

标签: php pdf iframe pdftk

我有一个显示交互式pdf表单。如何创建按钮以从pdf文档中获取数据。需要帮助,一整天都在这里。

这是应该获取pdf数据的php文件

if(isset($_POST) && is_array($_POST) && count($_POST)){

        $data=array();

$data['topmostSubform[0].Page1[0].Applicant_Surname[0]']=$_POST['topmostSubform_0__Page1_0__Applicant_Surname_0_'];
        $data['topmostSubform[0].Page1[0].Applicant_FirstName[0]']=$_POST['topmostSubform_0__Page1_0__Applicant_FirstName_0_'];

        // need the function definition
    require_once'createFDF.php';

    // some variables to use

    // file name will be <the current timestamp>.fdf
    $kui = time();
    /*$kui = time();*/
    $fdf_file=$kui.'.fdf';

    // the directory to write the result in
    $fdf_dir=dirname(__FILE__).'/results';

    // need to know what file the data will go into
    $pdf_doc='http://localhost/uniApp/results/fillsheet.pdf';

    // generate the file content
    $fdf_data=createFDF($pdf_doc,$data);

    // this is where you'd do any custom handling of the data
    // if you wanted to put it in a database, email the
    // FDF data, push ti back to the user with a header() call, etc.

    // write the file out
    if($fp=fopen($fdf_dir.'/'.$fdf_file,'w')){
        fwrite($fp,$fdf_data,strlen($fdf_data));
       /* echo $fdf_file,' written successfully.';*/
        system("pdftk fillsheet.pdf fill_form results/". $fdf_file. " output results/$kui.pdf flatten");
        $_SESSION['message'] = 'Your application has been updated';
        $message = 'written successfully.';
        echo $kui,' written successfully.';
        }else{
        die('Unable to create file:'.$fdf_dir.'/'.$fdf_file);
    }
        fclose($fp);
}

使用纯PHP代码时效果很好,但是当我从<iframe>

尝试时它不起作用

0 个答案:

没有答案