开发者

Get list of text-fields within PDF using PHP

开发者 https://www.devze.com 2023-02-08 11:06 出处:网络
I 开发者_高级运维have tried googleing this but can\'t seem to find an answer. I have a client that has hundreds of PDF files, each of them have a form with any number of text-fields within them... i

I 开发者_高级运维have tried googleing this but can't seem to find an answer.

I have a client that has hundreds of PDF files, each of them have a form with any number of text-fields within them... it could range anywhere from 2 text-fields to 30 text-fields... that is an unknown.

What I need to do is read the PDF file, find all of the text-fields (including field names) within the PDF file so that I can dynamically generate a HTML form that an user will complete which then populates the PDF form.

How can I get a list of text fields and their names within a PDF document using PHP?


There are few tools to work on PDFs that are natively written in PHP.

You might however be able to run the pdftk binary to accomplish this task:

$fields = `pdftk input.pdf dump_data_fields`;

Not tried since I don't have a PDF with forms handy. But supposely you get a textual result list as described here: http://www.cs.unb.ca/~bremner/blog/posts/filling_in_forms_with_pdftk/

0

精彩评论

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