【发布时间】:2013-11-01 23:26:35
【问题描述】:
我在 Livecycle Designer ES3 中创建了一个 PDF 表单。
我的工作是让提交按钮将整个 pdf 保存在服务器上的某个文件夹中。
该按钮指向我的 Web 服务器上的一个 php 文件。该按钮的类型为“提交”,并作为“URL 编码日期 (HTTP)”提交。
我试过了:
$file = $GLOBALS['HTTP_RAW_POST_DATA'];
$newfile = "/var/watchfolder/" . microtime(true) . ".pdf";
file_put_contents($newfile, $file);
我也试过了:
$file = file_get_contents("php://input");
$newfile = "/var/watchfolder/" . microtime(true) . ".pdf";
file_put_contents($newfile, $file);
他们两次都写了一个文件,但文件的内容是这样的:
OrderDate=&DocumentNo=&Concat_BuyfromVendorNo_BuyfromVendorName=&JobNo=&TicketNo=&Concat_SellToCustomerNo_SellToCustomerName=&LineNo_1=&No_1=&OutstandingQuantity_1=&Quantity_1=123&...
Reader 或 Acrobat 都不会将其作为有效的 pdf 打开。
如何让它写成 pdf 格式的文件?
更新:
* 我想通了。在 Livecycle 中选择“提交为:PDF”并将其指向您的 php 文件。
我的看起来像:
<?php
ob_start();
$file = file_get_contents("php://input"); //Gets binary PDF Data
$time = microtime(true);
$newfile = "/var/watchfolder/" . $time . ".pdf"; //Names xml file based on the time to the microsecond so nothing gets overwritten.
$worked = file_put_contents($newfile, $file); //Creates File
ob_end_clean();
$file = "/var/www/forms/Submission_Confirmation.pdf";
$filename = 'Submission_Confirmation.pdf'; /* Note: Always use .pdf at the end. */
header('Content-type: application/pdf');
header('Content-Disposition: inline; filename="' . $filename . '"');
header('Content-Transfer-Encoding: binary');
header('Content-Length: ' . filesize($file));
header('Accept-Ranges: bytes');
@readfile($file);
?>
最后一部分在阅读器中加载 PDF 作为确认。它可以是您想要的任何 pdf,包括刚刚提交的 PDF。
Reader 在 Acrobat 中扩展 PDF
填写并提交
瞧!
【问题讨论】: