How to edit and update the pdf file?

扶醉桌前 提交于 2019-12-10 18:26:33

问题


I am working on a web application using asp.net.

One of requirements demands that I open a given pdf file containing form fields, fill the fields like checking the check boxes, selecting the values from the select inputs and entering the text in text boxes etc.

Once the fields are set then I need to submit it to server and save this as a new pdf file or update the same pdf file.

I don't have a submit button in the pdf itself. I need to submit the details to server using a button outside the pdf file.


回答1:


When you have a file on a server and you serve it to a client, there are two instances of the file: one on the server and one on the client.

The end user can fill out the form on the client, but will need a button on the PDF if you want him to submit the data he entered to the server. This is explained here: Edit pdf embedded in the browser and save the pdf directly to server

Your requirement to have a button outside the PDF is in most cases impossible: it requires establishing communication between the PDF viewer and the browser. This is only possible in a very specific environment: it requires the Adobe Reader plug-in and it won't ever work on Mac. See also PDF hostContainer callback

You need to reconsider the requirement of having a button outside the PDF! I've been working on a similar project where the submit button was added to the form on-the-fly. The button was only visible on the PDF on the client. The client used that button to submit the data.

Once the data is submitted (see Edit pdf embedded in the browser and save the pdf directly to server to find out in which form the data can be transmitted), you can fill out the form on the server-side. This is explained here:

  • How to fill out a pdf file programatically?
  • Saving .xfdf as .pdf
  • ... (this is a very common question; a simple search will reveal more answers)

The form on your server is your template. I assume that this template will be served to many different people. If that is true, then you do not want to replace that template with a form that is filled out by the previous user! (This code cause some serious privacy issues.)

If you really want to update the PDF that exists on the server (instead of creating a new copy), you might also want to read the answer to this question: How to update a PDF without creating a new PDF?



来源:https://stackoverflow.com/questions/31892361/how-to-edit-and-update-the-pdf-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!