2013-03-20 117 views
0

我正在使用cakephp。我生成FDF文件使用的功能从http://koivi.com/fill-pdf-form-fields这个URL在safari中下载PDF文件5.1.7

它工作正常。然后我使用PDFTK生成PDF文件,并且有一些头文件可以在Firefox,Chorome和IE中正常工作,但它在Safari浏览器中效果不佳。在Safari浏览器中显示PDF文件代码。当我在命令末尾使用exit();时,safari会下载文件,但并不完整。

文件的正常大小是60Kb但是exit()它生成48Kb文件。所以它的意思是由于exit()命令错过了一些PDF文件内容。

如果有人能在Safari浏览器中给出一些提示来解决这个问题。 在此先感谢。

header('Content-Type: application/octet-stream'); 
header('Content-Disposition: attachment; filename="pdf_file_name.pdf"'); 
header("Content-Type: application/download"); 
header("Content-Length: " . filesize($pdf_doc)); 
header('Expires: 0'); 
header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); 
header('Pragma: public'); 
// $pdf_doc is the PDF Form physical path 
// $fdf_doc is the FDF file physical path 
echo passthru("/usr/local/bin/pdftk $pdf_doc fill_form $fdf_doc output - "); 
+0

我注意到,当显示在Safari浏览器的PDF代码,我点击刷新按钮,然后它给人的文件下载选项。 – nbhatti2001 2013-03-20 07:32:42

回答

2

尝试将其保存在磁盘上生成的文件使用PDFTK

以下命令
passthru("pdftk $pdf_doc fill_form $fdf_doc output test.pdf"); 

,然后使用相同的代码已经生成PDF你有。 尝试保存PDF文件

header('Content-Disposition: attachment; filename="pdf_file_name.pdf"'); 
header("Content-Type: application/download"); 
header('Content-Type:application/pdf'); 
header("Content-Length: " . filesize("test.pdf")); 
header('Content-Transfer-Encoding: binary'); 
header('Expires: 0'); 
header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); 
header('Pragma: public'); 
readfile("test.pdf"); 

希望以后下面的代码,这将在Safari工作,以及

0

header('Content-Type:application/pdf');

+0

没有工作。 – nbhatti2001 2013-03-20 07:29:34

+0

我认为是一个Safari错误,https://discussions.apple.com/thread/3906040?start=0&tstart=0 – Christian 2013-03-20 07:36:24