PHP可以处理作为完整PDF文档提交的PDF表单吗? [英] Can PHP handle a PDF form submitted as a complete PDF document

查看:354
本文介绍了PHP可以处理作为完整PDF文档提交的PDF表单吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

简而言之:



我有一个客户可以填写的PDF。当他们按下提交按钮时,我想自动发送附有完整PDF的电子邮件。这应该发生在服务器端,而不需要客户进一步的交互。



目前我有PDF设置将数据发布到服务器作为html格式的数据。我的PHP脚本然后处理这些数据,并发送一个纯文本电子邮件的数据。接收电子邮件的人喜欢拥有实际的PDF副本,而不仅仅是纯文本。所以,在Adobe Acrobat 9 Pro中,我将提交按钮设置为提交为PDF完整文档(如下所示)。



$ _ FILES 数组的一部分上传到服务器,但是 print_r($ _ FILES)显示空数组,以及 $ _ FILES $ _ POST count c>是 0



所以我的问题是,上传的pdf发生了什么?有什么我可以用PHP做的PDF转换成电子邮件附件?我不认为我遇到了文件大小的问题; post_max_size 为2MB,而PDF仅为〜725kb。




实际上,我最终将FDF数据发送到服务器,而不是整个PDF。这意味着我不得不在我的PHP中编写一大堆乱码来处理FDF,但总的来说,它只是一个较小的上传,并且满足了客户的要求。如果您真的需要上传整个PDF,帕特里克的答案在下面应该是正确的 - 你应该能够找到上传pdf在 $ GLOBALS ['HTTP_RAW_POST_DATA']

解决方案

$ GLOBALS ['HTTP_RAW_POST_DATA']拉取原始的PDF数据。您可以输出到一个文件,并打开它,就像任何PDF文件一样。


In Short:

I have a PDF that customers can fill out. When they press the "Submit" button, I want to automatically send an email with the completed PDF attached. This should happen server-side with no further interaction from the customer.

In Long:

Currently I have the PDF set to post the data to the server as html form data. My PHP script then processes this data and sends a plain text email with the data. The people receiving the email would prefer to have a copy of the actual PDF, not just plain text.

So, in Adobe Acrobat 9 Pro, I set the Submit button to submit as "PDF The complete document" (as seen below).

The problem is, I don't know what to do in PHP to handle this. I assumed it would upload to the server as part of the $_FILES array, but print_r($_FILES) shows an empty array, and the count of both $_FILES and $_POST is 0.

So my question is, what's happening to the uploaded pdf? and is there anything I can do with PHP to turn that pdf into an email attachment? I don't think I'm running into issues with the file size; the post_max_size is 2MB, and the PDF is only about ~725kb.


I actually ended up sending the FDF data to the server instead of the whole PDF. This meant I had to write a whole bunch of gibberish into my PHP to handle the FDF, but all-in-all it's a smaller upload and it meets the customer's requirements. If you really need to upload the whole PDF, Patrick's answer below should be correct -- you should be able to find the uploaded pdf in $GLOBALS['HTTP_RAW_POST_DATA'].

解决方案

You can pull the raw PDF data from $GLOBALS['HTTP_RAW_POST_DATA']. You can output this to a file and open it as you would any PDF.

这篇关于PHP可以处理作为完整PDF文档提交的PDF表单吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆