开发者

Is there a native PHP class/library that supports fill_form with xfdf?

开发者 https://www.devze.com 2022-12-17 13:54 出处:网络
First, I have researched this on SO and Google already. In fact, based on this, I\'m pretty skeptical that what I need exists. I\'m almost at the point where I might give up the next 6 months of my li

First, I have researched this on SO and Google already. In fact, based on this, I'm pretty skeptical that what I need exists. I'm almost at the point where I might give up the next 6 months of my life to write something from scratch, since it seems obvious that everyone wants a server-side form filler native to PHP.

Okay, sorry for the rant...

Here is my situation:

1.I need to deliver pre-filled PDF forms to my users.

Because the form is behind cookie-based authentication, Adobe Reader won't open the xfdf, but instead passes the task along to the browser. This is an issue for Linux users and other users who don't use Adobe Reader as their PDF reader.

Oh, and Adobe hasn't written a 64-bit plugin for Snow Leopard yet, so a third of my users have to change Safari to run in 32 bit mode every time they print this form.

Given the above, delivery of the PDF already filled in so that it can b开发者_如何学JAVAe printed in Preview, Foxit, etc, is steadily becoming the most obvious solution.

2. I can't use pdftk

This is a bit silly, but since pdftk is ancient and requires gcj to compile the outdated version of itext that it uses, I can't install pdftk on my host machine. The server doesn't have gcj, and I'd rather avoid requesting that it be installed for this one case.

Also, even if I could install pdftk, I can only do passthru() and other command-line operations via CGI, which I'd also like to avoid.

3. My host currently does not have PDFLib installed,

so I can't use the PDF extension in php. Not that it offers this feature, but I thought maybe it could be used to add the fdf dictionary to the generic form, the same way that itext/pdftk does.

I thought all was lost until I learned about TCPDF and FPDF. It looks like TCPDF has the stronger track record, and more features, but I can't find anything on Google or their documentation about server-side form filling.

If this isn't already obvious, I don't need a library for generating FDFs or XFDFs. I already have that down. But it is proving not to be enough for my users who simply want the combined product.

So I guess my questions are:

  1. Is there a pre-built method for outputting a new PDF that is the generic form with the data from an XFDF filled in?

  2. If not, is there a work around that doesn't entail simply writing in the values on top of the form fields (as opposed to within the fields)? Writing the values on top of the fields means that the javascript won't validate the values and that I'd need to manually change the stream values every time.

  3. If no to both, is there a port of pdftk I haven't found yet that works with PHP and doesn't simply call the binary via command line?

Any help with this is greatly appreciated. If anyone wants to volunteer to help me make such a library, let me know, I'm already hard at work trying to learn PDF syntax, just in case.


TCPDF allows delivering forms pre-filled. Please checkout their example at - http://www.tcpdf.org/examples/example_014.phps , especially the date field and radio buttons in it.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号