How To Fill A Fillable PDF Form with PHP using PDFtk

preview_player
Показать описание
How to fill a PDF using PHP?

Have you ever wanted to know how to grab data from a form on a website and have it fill an already existing fillable PDF? Maybe you have a PDF with a form in it that you want to be filled in from a web form, so that it keeps the look and feel of your PDF with the data. Of course, you can fill in the PDF using Adobe Reader but what if your website form did it instead?

Well, PDFtk, along with PHP can help you achieve just that.

This simple video will show you how to do it. I'll be creating a simple project showing you how to fill PDFs on your website.
I will not be doing form validation so that is something you will want to do if you plan on sending the project live. Don't
forget to do front end and back end validation.

PDFtk is a free tool for PDF Manipulation, and there is also a PDFTK Server, which we can use with PHP to manipulate PDFs.

Many other PDF libraries do not fill PDFs or make it very difficult to do so, PDFtk with php-pdftk is very simple to use.

PDFTk does not only fill PDFs, it can join PDFs together, it can remove files and add files. It can split files, add overlays and even
grab data from a PDF to use in PHP. This tutorial will simply show you how to fill PDFs, but the php-pdftk library can be used for more things.
Рекомендации по теме
Комментарии
Автор

If you don't have adobe acrobat pro and want to find out the field names in a PDF - you can do it using pdftk [PDFNAME].pdf dump_data_fields - run this in terminal in the same folder the .pdf file is in, it will spit back all the fields and their names so you can map them with php pdftk.

mrdigitalau
Автор

Great explanation Mr Digital!. Thank you very much.

saddamhossain-drfx
Автор

BEFORE WATCHING THIS: Make sure you can install PDFtk on your server. This video is great and everything will work fine on your localhost. But you can't get it on many servers, especially if they are shared (unless someone out there has a workaround...???). Just a warning before you waste a bunch of time learning this.

laurenmarie
Автор

Great tutorial. Clear and concise and useful.

lonnydavis
Автор

great tutorial thank you very much it saves lots of time.

rachitshah
Автор

I tried to fill in a digital signature field but it didn't work. Is it possible to fill a digital signature field?

屍心
Автор

Hi..how about if the pdf form has checkbox? How to fill it?

southbridgetech
Автор

Is it possible add text like a header or a footer on a existing PDF and display it to the user (on the browser) using PDFtk?

cellocarlos
Автор

Hello Mr. Digital, thanks for the great video, but I'm not getting any output PDF generated in the completed folder. any help would be apricated.

leopascal
Автор

Hey Sean, it looks like I have everything working, however, when I click download PDF it says, Failed - No file in the downloads. Any idea why?

christopheransbaugh
Автор

Can we fillable some field and then flatted it and other fields must be fill when open it with Reader or Acrobat?

SongvitItthiphisit
Автор

it appears at first glance that you did not create a fillable pdf, you created a form that created a flat pdf. I need a fillable pdf that has some parts filled in from a database source while the client gets to fill in the rest and send it back to me.

SirWebbie
Автор

I have some issues hqving the new pdf in the completed folder. I'm using Hostinger by the way, so it's not local server

So when I try to download the pdf from the link, I receive this error, "file wasn't available "

TIFO
Автор

Just tested it on a Win 10 Machine with Version 1909, webserver is over XAMPP.
Code seems to be working fine so far, the only thing is that the pdf is just not generated, so there is no file saved...
Also can't see any errors with the getError() - method.. any help?

devmev
Автор

Perfect explanation brother. Can we do the auto height based on the input text length?

sanghisa
Автор

I need the metadata from the original PDF also appear in the generated PDF. Will this code generate a brand new pdf file or make a copy of the existing PDF (i.e., test.pdf) and simply add form entries from PHP form page into it?

junkmatrix
Автор

Hi, I have an add button on my PDF to generate dynamic fields. How I can generate and fill data dynamically using PHP?

sagaciouselevate
Автор

I have a fillable PDF, after opening it in the browser, filling it with data, I want to save it as PDF. any help will be appreciated.

rosedematta
Автор

Hello sir, i have the problem...my problem is processed pdf not saved to completed directory...

afiqurrahman
Автор

after downloading it shows me Failed -No file ... how can I fix it i could not get any Solution till yet...please i need some help

abdullaalrakib
welcome to shbcf.ru