0

我有一个在线 Acrobat 表单,用户填写并选择提交按钮。我定义了提交按钮以将完整的 PDF 文件发送到一个 php 程序,该程序只需将文件附加到电子邮件 (phpMailer) 并发送它。

我想做的是与静态表单名称一起发送,即 Acrobat 表单中的客户名称字段值。因此,如果客户在 Customer_Name 字段中输入“John Doe”,我希望在提交中包含以下内容。

../submit_pdf_form.php?form=New_Patient&Customer_Name=John Doe

这在 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

所以我终于想出了如何从 adobe 在线表格中获取信息。

杂技演员:

在 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 回答