是否有可能合并FDF数据用PDF格式的文件,使用PHP一个人吗?或者是没有选择,只能使用第3党的命令行的工具来实现这一目标?

如果是这种情况下可以有人指给我方向的一个吗?

我目前输出的FDF文件的浏览器中的希望,这将向用户的满PDF但对某些人来说,不是这种情况。FDF内容是被输出到屏幕上,即使我用header('Content-type:应用/越南盾。fdf');

有帮助吗?

解决方案

有关将来参考,它看起来像没有这样做没有第三方应用程序的可靠方法。 PDFTK( http://www.accesspdf.com/pdftk/ )结束了是我的解决方案。

我首先产生的在FDF文件如前,然后使用以下PHP代码合并到我的PDF文件

header('Content-type: application/pdf');
header('Content-Disposition: attachment; filename="Download.pdf"');
passthru("pdftk file.pdf fill_form data.fdf output - ");
exit;

这比我想象的要容易得多。这瞬间,无需破解周围的头和文件扩展名,以确保所有浏览器在处理一个FDF正确的,因为它只是使浏览器下载的PDF文件。

如果你想要的PDF输出文件不再是可编辑的,使用

    passthru("pdftk file.pdf fill_form data.fdf output - flatten");

道歉,如果这是基本的东西,只是觉得应该把它们都放在一个地方,让人们不要去通过我忍着头痛。

N.B。如果没有设置PATH变量,你需要使用的完整路径PDFTK即。

    passthru("/usr/local/bin/pdftk file.pdf fill_form data.fdf output - flatten");

其他提示

还有另一种方式的一天,不使用passthru也不pdftk但是,仅仅一个脚本在2004年但仍然在工作: forge_fdf

它可以帮助你们建立一个fdf,你可以在涵盖一些straithly在你pdf,这意味着你

保存这一php文件,我们说generatePdf.php

require_once('forge_fdf.php');  

// leave this blank if we're associating the FDF w/ the PDF via URL
$pdf_form_url= "";


// default data; these two arrays must ultimately list all of the fields
// you desire to alter, even if you just want to set the 'hidden' flag;
//
//
$fdf_data_names= array(); // none of these in this example
$fdf_data_strings= array(); // none of these in this example

$fdf_data_strings['email']=mb_strtolower($row_delivreur['firstname']).'.'.mb_strtolower($row_delivreur['lastname']).'@gmail.com';

$fields_hidden= array();
$fields_readonly= array();

// set this to retry the previous state
$retry_b= false;

header( 'content-type: application/vnd.fdf' );

echo forge_fdf( $pdf_form_url,
        $fdf_data_strings, 
        $fdf_data_names,
        $fields_hidden,
        $fields_readonly );

做一个链接到Pathtoyourpdf/nameofpdffile.pdf#FDF=generatePdf.php 将会打开你的PDF文件在浏览器(或者有一种方法来保存它向盘我想我记得)和领域的电子邮件将数据填充MYSQL: mb_strtolower($row_delivreur['firstname']).'.'.mb_strtolower($row_delivreur['lastname']).'@gmail.com'

它的工作与选择框,无线电按钮...它打开了在火狐,它将测试与其他浏览器。

更多的相关信息上的 PDF黑客

迄今为止最简单的方法,我发现安装在CentOS PDFTK:

安装rpmforge软件库 - http://wiki.centos.org/AdditionalResources/库/ RPMForge软件#头5aabf02717d5b6b12d47edbc5811404998926a1b

然后

百胜安装PDFTK

和这就是它!

http://www.setasign.de /产品/ PDF的PHP-溶液/ FPDI /演示/串连仿/

这个作品中,类下载从网站挂过,

它不需要中继/ exec命令并没有额外的扩展。

编辑说,这不符合新的PDF版本1.5以上,恢复到PDFTK工作,繁琐,但使用Exec命令与所有PDF作品。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top