2013-11-01 27 views
0

我試圖通過Adobe Reader或Foxit6提交pdf時返回一個動態字符串作爲響應。我已經編寫了代碼來完成Adobe的這一操作,但是Foxit僅顯示一個警告框,指出提交是否成功(「您的表單提交成功!」)或不顯示(我無法引發此提示)。如果可能,我想操縱提示的文本,否則會顯示響應消息。福昕PDF閱讀器創建動態響應

在提交接收代碼中,我會做一些驗證& MYSQL查詢,我希望能夠向用戶表達任何錯誤或紅旗。

作爲一方,我使用pdftk創建動態pdf,因爲它已經在服務器上了,我想避免使用額外的庫,雖然我使用的過程確實感覺有點過於複雜。

這裏的流量:

  1. 用戶提交使用與出口格式的「提交表單」書籤PDF文件:HTML。
  2. PHP:
    • 收集的$ _ POST值
    • void驗證
    • 保存到數據庫
    • 生成爲FDF

我的代碼工作對Adobe的響應,但不福昕:

<?php 
ob_start(); 
foreach($_POST as $key=>$val){ 
    if(!$reader && strpos($key,"Content-Disposition:_form-data;_name")){ 
     $reader="Foxit"; 
     $regex="/\"(.*)\"\r\n\r\n(.*)\r\n/"; 
     if(preg_match_all($regex,$val,$matches)){ 
      $count=sizeof($matches[1]); 
      for($x=0; $x<$count; ++$x){ 
       $array[$matches[1][$x]]=$matches[2][$x]; 
      } 
     } 
     break; 
    }else{ 
     $array["$key"]=$val; 
     if(!$reader){$reader="Adobe";} 
    } 
} 

// validation section, redflags are added to $alert 

// connect to DB and INSERT INTO mysql query, errors added to $alert 

if($reader!="Foxit"){ // hands tied at the moment -- no way to directly display a response to user 
    /* Submitting URL must be appended with "#FDF" so source pdf knows to expect an FDF as response */ 
    header("Content-type: application/vnd.fdf"); 
    if(!$alert){$alert="Submission Successful";} 
    echo "%FDF-1.2\n%âãÏÓ\n1 0 obj\n<<\n/FDF\n<<\n/Status($alert)\n>>\n>>\nendobj\ntrailer\n<</Root 1 0 R>>\n%%EOF"; 
} 

ob_end_flush(); 
?> 

回答

0

看來我想要的結果在Foxit上是不可能的。