0

ユーザーが入力して [送信] ボタンを選択するオンラインの Acrobat フォームがあります。完全なPDFファイルをphpプログラムに送信するように定義された送信ボタンがあり、ファイルを電子メール(phpMailer)に添付して送信するだけです。

私がやりたいことは、Acrobat フォームからの静的フォーム名、顧客名フィールドの値とともに送信することです。したがって、顧客が Customer_Name フィールドに「John Doe」と入力した場合、送信には次のように入力します。

../submit_pdf_form.php?form=New_Patient&Customer_Name=ジョン・ドウ

これは Acrobat Pro X で可能ですか? どうやってするの。

ありがとう

-- PHP pgm ソース コードのハイライト --

<?php
// what form are we sending
if (isset($_GET['form']))    { $form_type = $_GET['form']; }
//////////////////////////////////////////////////
//// this is the catching of the PDF
///////////////////////////////////////////////////
if(!isset($HTTP_RAW_POST_DATA)) 
{
    echo "The Application could not be sent. Please save the PDF and email it manually.";
    exit;
}
//////////////////////////////////////////
// Create PDF file with the filled data
//////////////////////////////////////////
$semi_rand = $form_type . time();
$pdf = $HTTP_RAW_POST_DATA;
$file = $semi_rand . ".pdf"; 
$handle = fopen($file, 'w+');
fwrite($handle, $pdf);   
fclose($handle);
/////////////////////////////////////////
require_once("\phpMailer\class.phpmailer.php");
...
set up mail
...
if(!$mail->AddAttachment($file))
    {
        echo "There was a problem attaching the pdf.";
        echo $mailer->ErrorInfo;
    }
 if(!$mail->Send()) {
    $error = "Error sending Email ".$mail->ErrorInfo; 
        echo $error; }
4

1 に答える 1

1

だから私は最終的にアドビのオンラインフォームから情報を取得する方法を見つけました.

アクロバット:

Acrobat でボタンを作成し、アクションで [マウス ダウン] でトリガーを選択し、アクション [JavaScript を実行] を選択して、[追加] をクリックします。ポップアップ ウィンドウで、次のようなものを追加してフォーム フィールドを取得し、フォームを別のプログラムに送信して、phpmailer 経由で電子メールで送信します。これにより、PDF ファイル全体がプログラムに送信されます。

var name = getField("Shipper Name").valueAsString;  // get name field
name = name.replace(/(^[\s]+|[\s]+$)/g, '');        // trim spaces 
name = name.replace("'", "\\'");                    // change O'Neil to O\'Neil 
name = "'"+name+"'";
var email = getField("Shipper Email").valueAsString; // get email address
email = email.replace(/(^[\s]+|[\s]+$)/g, '');      // trim spaces from front and end
console.println("Your Email is Being sent to you and Dr. xxxxxx");
this.submitForm({
cURL: "../submit_pdf_form.php?form=New_Patient_Form&name="+name+"&email="+email,
cSubmitAs: "PDF"                                   // select form type PDF, FDF

});

Acrobat ボタンの定義に関する追加のヘルプについては、以下のリンクを参照してください。

http://www.w3.org/WAI/GL/WCAG20-TECHS/PDF15.html

PHP 次に、情報を PHP プログラムに取り込み、次のように送信できます。

<?php
include("class.phpmailer.php");        
// what form are we sending
$form_type = "";
$cust_name = "";
$cust_email = "";
if (isset($_GET['form']))  { $form_type = $_GET['form']; }
if (isset($_GET['name']))  { $cust_name = $_GET['name']; 
                           $temp = "\'";
                           $cust_name = str_replace($temp, "'", $cust_name);
                       }
if (isset($_GET['email'])) { $cust_email = $_GET['email']; }
//////////////////////////////////////////////////
//// this is the catching of the PDF
///////////////////////////////////////////////////
if(!isset($HTTP_RAW_POST_DATA)) 
{
    echo "The Application could not be sent. Please save the PDF and email it manually.";
    exit;
}
///////////////////////////////////////////////////
// Create PDF file with the filled data
///////////////////////////////////////////////////
$semi_rand = $form_type . "-" . date("s", time());
$pdf = $HTTP_RAW_POST_DATA;
$file = $semi_rand . ".pdf"; 
$handle = fopen($file, 'w+');
fwrite($handle, $pdf);   
fclose($handle);
///////////////////////////////////////////////////
//// this is the Emailing of the PDF
/////////////////////////////////////////////////// 
$mail_subject = "Patient Web Forms: " . $form_type;
$mail_message = "Patient submitted webform: \n" . $form_type . "\n Form from " . $cust_name . "\n Patient email: " . $cust_email;
$mail_from = "someone@comapny.com";
$mail_from_name = "Web Forms";
$mail_host = "smtp.company.net";
$username = "johndoe";
$password = "password"; 
$mail_to = "johndoe@company.com";                  // ---- use comma as separators
// --- look for localhost vs production ----
if ($_SERVER['HTTP_HOST'] == "localhost")             // -- test mode  ?
{
    $mail_to = "johndoe@testcom.com";
}
else
{
    $mail_to = "johndoe@company.com";
}
$message = "";

$mail = new PHPmailer(true);  // create a new object  (true = displays error messages) 
$mail->IsSMTP();          // enable SMTP
$mail->SMTPDebug = 0;         // debugging: 0 = off, 1 = errors and messages, 2 = messages only
// $mail->SMTPAuth = true;    // enable SMTP authentication
$mail->Port = 25;
$mail->Host = $mail_host;
$mail->Username = $username;  
$mail->Password = $password;           
$mail->SetFrom($mail_from, $mail_from_name);
$mail->Subject = $mail_subject;
$mail->Body = $mail_message;
$mail->AddAddress($mail_to);

if(!$mail->AddAttachment($file))
{
    $message = "There was a problem attaching the pdf.";
    echo "There was a problem attaching the pdf.";
    echo $mail->ErrorInfo;
    die;
}

if(!$mail->Send()) {
    $message = "Error sending Email ".$mail->ErrorInfo; 
} 
else 
{
    $message = "Form emailed to Dr Pearson's office";
}

$mail->ClearAddresses();
$mail->ClearAttachments();
unlink($file);              // delete the temporary pdf file then redirect to the success page
header("location: patients.php?msg=$message");

unlink($file);  //doubley make sure the temp pdf gets deleted
?>
于 2012-11-06T06:24:45.110 に答える