How To Fill A Fillable PDF Form with PHP using PDFtk

Поделиться
HTML-код
  • Опубликовано: 25 окт 2024

Комментарии • 133

  • @mrdigitalau
    @mrdigitalau  4 года назад +8

    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.

    • @prane81
      @prane81 4 года назад

      Mr Digital thank you

    • @coraspa4091
      @coraspa4091 2 года назад

      Hello Mr Digital, If we have sample pdf but in current adobe we can't edit the form field name & also using pdftk can't fill form properly with fdf. So is it pdf issue ?

  • @laurenmarie2035
    @laurenmarie2035 3 года назад +2

    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.

    • @artkazun
      @artkazun 3 года назад

      so you can't just copy the existing project with the installed PDFtk from the localhost to your shared server?

    • @laurenmarie2035
      @laurenmarie2035 3 года назад +1

      @@artkazun Exactly. It won't work. The company you have your server with has to have PDFtk on their platform and you can't install it yourself. This is if you have a shared server.

    • @keremardicli4013
      @keremardicli4013 2 года назад

      @@laurenmarie2035 there are some pdftk composer packages out there based on pdftk. Would they work?

  • @saddamhossain-dr9fx
    @saddamhossain-dr9fx Год назад

    Great explanation Mr Digital!. Thank you very much.

  • @rachitshah6993
    @rachitshah6993 3 месяца назад

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

  • @creativeartdesign4820
    @creativeartdesign4820 2 года назад +1

    Good work, i only have one question.
    Can i use it on my hosted webserver? what files do i need to upload to the hosting company ?
    Or did i understand it wrong, it is only need to be installed on the client? the plugin? PDFTK.

    • @masonholt651
      @masonholt651 2 года назад

      I have the same question. Did you ever find an answer?

    • @creativeartdesign4820
      @creativeartdesign4820 2 года назад

      @@masonholt651 No answer..yet.

    • @masonholt651
      @masonholt651 2 года назад +1

      @@creativeartdesign4820 I did a little more digging yesterday, and it seems like you need a dedicated server for this, and then this software has to be installed on it. Shared hosting just won't allow this software on it.

  • @lonnydavis5586
    @lonnydavis5586 3 года назад

    Great tutorial. Clear and concise and useful.

  • @leopascal4812
    @leopascal4812 4 года назад +4

    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.

    • @dlk9572
      @dlk9572 3 года назад

      hello, did you find a solution?

    • @ferdinandiszlai8896
      @ferdinandiszlai8896 3 года назад

      I have the sam issue... it only generates the filename and prints it out to the screen.. it does not genereate the pdf. :(

  • @markusj3029
    @markusj3029 Год назад

    It looked very good at first sight. But if I got it right, it`s necessary to install pdftk-server. It might be easy on localhost, but how can I bring it to work on my productive site?!

    • @sthembisoncwane3412
      @sthembisoncwane3412 6 месяцев назад

      Absolutely, @markusj3029, one effective approach to deploy the application form for your productive site is by hosting it on a virtual machine like AWS EC2. I've successfully hosted the application form on AWS EC2, which grants you complete control over the environment and facilitates the installation of necessary dependencies. Additionally, I've integrated additional libraries such as PHPMailer for seamless emailing of the application submissions and Fpdi for facilitating digital signatures. This setup ensures enhanced functionality and reliability for your application form. If you require further assistance or guidance on this setup, feel free to let me know!

  • @TIFO39
    @TIFO39 8 месяцев назад

    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 "

  • @christopheransbaugh3946
    @christopheransbaugh3946 3 года назад +2

    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?

    • @maxfxch
      @maxfxch 3 года назад

      Hi Christopher, got the same issue here, did you find a way to resolve this ?

    • @christopheransbaugh3946
      @christopheransbaugh3946 3 года назад

      @@maxfxch Yes, I did fix the issue. It was something super simple but I can't remember exactly what it was. I would recommend that you make sure whatever local server you're using has the most up -to-date PHP installed and also that you've installed Pdftk properly.
      You also should also ensure that all of your filepaths in the code are correct.

    • @maxfxch
      @maxfxch 3 года назад

      @@christopheransbaugh3946 Thanks for your concern. I updated everything I'm using PHP 8, using XAMPP for Php 8 still not working my short path are good too. I'll dig to find out a solution. Thanks !

    • @dlk9572
      @dlk9572 3 года назад

      @@maxfxch hello, did you find a solution?

    • @autoleader3441
      @autoleader3441 2 года назад

      Check bame of New pdf (‘(namefile.pdf)’) its same name of your file ?

  • @jim9408
    @jim9408 3 года назад

    Hey Sean, Thank you. Your teaching style makes understanding the whole process easy to grasp. Have you used this same process (php-pdftk) for having someone electronically sign the PDF document?

    • @mrdigitalau
      @mrdigitalau  3 года назад

      Hello Jim, thank you very much. I don't use PDFTK for signatures because it is more used just to fill pdfs. If you want signatures it might be best to use DOMPDF or MPDF for that.
      You've given me a good idea for a tutorial, thanks mate!

    • @diangrove6931
      @diangrove6931 2 года назад

      @@mrdigitalau , I have the same question as Jim. Have you managed to make a tutorial on signing the PDF? Also which one DOMPDF or MPDF is best to use for this. Thanks mate.

    • @sthembisoncwane3412
      @sthembisoncwane3412 6 месяцев назад

      @@diangrove6931 hey what i did is to use PDFtk for text and FPDi for signatures and it works great.

  • @sanghisa
    @sanghisa 2 года назад

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

  • @TheRamiroB
    @TheRamiroB 3 года назад

    great video!!
    One question I looking for any tool that can I embed inside my app, for generate pdf forms? do you know some app?

  • @cellocarlos
    @cellocarlos Год назад

    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?

  • @DavidsonJasmin
    @DavidsonJasmin 3 года назад

    Thank you Mr. Digital.

  • @devmev2665
    @devmev2665 4 года назад +1

    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?

    • @devmev2665
      @devmev2665 4 года назад +8

      JUST FIXED IT! : It seems like this behaviour is known on windows systems, this lines (command and useExec) fixed it for me:
      $pdf = new Pdf('/path/my.pdf', [
      'command' => '/some/other/path/to/pdftk',
      // or on most Windows systems:
      // 'command' => 'C:\Program Files (x86)\PDFtk\bin\pdftk.exe',
      'useExec' => true, // May help on Windows systems if execution fails
      ]);
      Also add this line after the save as:
      // Check for errors
      if (!$pdf->saveAs('my.pdf')) {
      $error = $pdf->getError();
      }
      you have then the possibilty to log errors -> there i saw that i also have to use an absolut path for the "new PDF" -> 'C:\xampp\htdocs\test.pdf'
      Source: github.com/mikehaertl/php-pdftk#execution
      Edit: use the Full Windows Path also at the PDF File, thanks to the comments !

    • @happlyfly
      @happlyfly 4 года назад

      @@devmev2665 Very helpful. I am getting the same fruitless outcome - after seeing your comment, realized that its not just me. Unfortunately the above advice did not work for me...... still no pdf file is being generated or saved... Any kind suggestion will be very helpful.

    • @leopascal4812
      @leopascal4812 4 года назад +1

      @@devmev2665 Hello Jul Pod, I've tried this by implementing your msg also but still no success, any help would be apricated.

    • @Phop279
      @Phop279 3 года назад

      @@devmev2665 Needs to use the full windows path for pdf file too. Now It's work thanks

    • @ferdinandiszlai8896
      @ferdinandiszlai8896 3 года назад

      @@devmev2665 If i could hug you You would get a big fucking HUG!!

  • @afiqurrahman2884
    @afiqurrahman2884 2 года назад

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

  • @sakuragi9785
    @sakuragi9785 2 года назад

    to create the route of this
    is a post or a get route? (Route::get/Route::post)

  • @junkmatrix
    @junkmatrix 4 года назад

    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?

  • @SongvitItthiphisit
    @SongvitItthiphisit 3 года назад

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

  • @dlk9572
    @dlk9572 3 года назад +1

    Hello, it's seem to work but the pdf file isn't generated can you help me please?

    • @Richard-wb8vo
      @Richard-wb8vo 3 года назад

      hi did you find a solution to this problem? I have the same and when I print the error in Mac OS it says command not found, thanks for help

  • @kyopan23
    @kyopan23 4 месяца назад

    How would you include a checkbox?

  • @MrJWVolleyball
    @MrJWVolleyball Год назад

    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.

  • @sagaciousip
    @sagaciousip 3 года назад

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

  • @scirpoliwebstudio5383
    @scirpoliwebstudio5383 2 года назад

    congratulations for the tutorial. simple and direct language. i was able to follow it and get my application to work. however, it only works locally. why when I publish on my domain it doesn't generate the pdf file for me? thank you

    • @mrdigitalau
      @mrdigitalau  2 года назад

      Hi there, Thank you. You need to install PDFtk on your server. What server are you running?

    • @scirpoliwebstudio5383
      @scirpoliwebstudio5383 2 года назад

      @@mrdigitalau Linux shl-buildd-bs03 4.19.0-22-amd64 #1 SMP Debian 4.19.260-1 (2022-09-29) x86_64 GNU/Linux

    • @mrdigitalau
      @mrdigitalau  2 года назад

      @@scirpoliwebstudio5383 Do you know how to SSH in and run commands by any chance? Using Putty or something similar? If you go here: snapcraft.io/install/pdftk/debian, run the commands on command line on your server, it should install it.

    • @scirpoliwebstudio5383
      @scirpoliwebstudio5383 2 года назад

      @@mrdigitalau great. Thank you very much. I try, I hope to succeed and after the test I will let you know if I succeeded. Thanks for answering me :)

    • @mrdigitalau
      @mrdigitalau  2 года назад

      @@scirpoliwebstudio5383 You are welcome mate. Let me know either way. Hope you get it working. Cheers

  • @abdullaalrakib3652
    @abdullaalrakib3652 2 года назад

    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

  • @usermiamiusa
    @usermiamiusa Год назад

    Hello, i excellent tutorial but i download your project but still getting error: Fatal error: Uncaught Error: Class 'Classes\GeneratePDF' not found in C:\xampp\htdocs\generate.php:23 Stack trace: #0 {main} thrown in C:\xampp\htdocs\generate.php on line 23

  • @happlyfly
    @happlyfly 4 года назад

    Hi Mr. Digital- thanks for this great tutorial. Unfortunately, I am ending up with no saved file in the "completed" directory- cannot understand why. Any kind suggestion to resolve the problem will be very helpful. Thanks again!

    • @happlyfly
      @happlyfly 4 года назад

      Hi again Mr. Digital- any advise for me to resolve the "failed" outcome of the project? Thank you.

    • @vslslss4293
      @vslslss4293 4 года назад

      same problem here

    • @happlyfly
      @happlyfly 4 года назад

      @@vslslss4293 In the GeneratePDF file, please start with "namespace Classes;". This has to be the first line in the file for the whole thing to work

    • @cheikh_mutazila
      @cheikh_mutazila 4 года назад

      same problem

    • @ramg7808
      @ramg7808 3 года назад +1

      Hi. It doesnt work with open server, but it works with laragon. Maybe it because of Apache or Mysql

  • @Richard-wb8vo
    @Richard-wb8vo 3 года назад

    Hi, I followed everything and this script does not end like yours do. I tried it in Mac OS with localhost, in Windows with WAMPP and onto my hosting server and every time I don't get anything, I tried also to download your code form GitHub and the only thing I got Is a file .pdf.html that has problems to open, I really don't know what to do, can you help me?

    • @dixon4946
      @dixon4946 2 года назад

      Hi , did you find something for this

  • @albachirbenhammad1169
    @albachirbenhammad1169 3 года назад

    I got this error : Warning: copy(): The second argument to copy() function cannot be a directory in C:\xampp\htdocs\Project\vendor\mikehaertl\php-pdftk\src\Pdf.php on line 576
    string(14) "pdf_255638.pdf"
    How Can I fix that!

  • @rosedematta4789
    @rosedematta4789 4 года назад

    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.

  • @pietrolechthaler747
    @pietrolechthaler747 4 года назад

    Mr Digital, Can I use this library without the composer? Can I download the library manually?

    • @mrdigitalau
      @mrdigitalau  4 года назад

      Hi Pietro. Yes you can, grab it off GitHub - github.com/mikehaertl/php-pdftk

  • @pietrolechthaler747
    @pietrolechthaler747 4 года назад

    Hi Mate, I want create an invoice file with my database's data. Do u think is a good way using this library?

    • @mrdigitalau
      @mrdigitalau  4 года назад +1

      Hi Pietro. If it were me, I would not use PDFTK for creating invoices. Unless the invoice is a fillable PDF. Otherwise you can use something like mPDF to create the PDF using HTML pulling data from the database.

  • @harshgodhani1782
    @harshgodhani1782 2 года назад

    I try to use this demo but it is not working.
    PDF is not generating.
    any suggestion?

    • @mrdigitalau
      @mrdigitalau  Год назад

      You might not have PDFTK installed on your system, do you?

  • @rohanshrestha8302
    @rohanshrestha8302 2 года назад

    Can we change the font of the pdf using pdftk?

  • @hakimfazal426
    @hakimfazal426 3 года назад +1

    how can we insert image.

  • @krzyracergt
    @krzyracergt 3 года назад +4

    For anyone having issues with generating pdf, I got it to work by using an absolute path.
    $pdf = new Pdf('C:\xampp\htdocs\pdfgen\test.pdf', [
    'command' => 'C:\Program Files (x86)\PDFtk Server\bin\pdftk.exe',
    'useExec' => true
    ]);
    $pdf->fillForm($data)
    ->flatten()
    ->saveAs('C:\xampp\htdocs\pdfgen\completed/' .$filename);
    return $filename;

    • @badchuckle
      @badchuckle 3 года назад +1

      this worked so well thank you

    • @sakuragi9785
      @sakuragi9785 2 года назад

      does anyone know the command for ubuntu?

    • @Src4mblerr
      @Src4mblerr 2 года назад +1

      Thank you so much! This worked!!!

    • @raoufdiak5453
      @raoufdiak5453 2 года назад

      Man you save my **s :D thanks

    • @niyazahamed8352
      @niyazahamed8352 2 года назад

      Thank You that worked , All we have to do is "GeneratePDF.php" and replace these (Check your personal file location)
      $pdf = new Pdf('C:\xampp\htdocs\pd\test.pdf', [
      'command' => 'C:\Program Files (x86)\PDFtk\bin\pdftk.exe',
      'useExec' => true
      ]);

      $pdf->fillForm($data)
      ->flatten()
      ->saveAs('C:\xampp\htdocs\pd\completed/' .$filename);

      return $filename;

  • @sippy28
    @sippy28 4 года назад +2

    But what about an image pdf form field?

    • @hakimfazal426
      @hakimfazal426 3 года назад

      did you found any solution?

    • @sthembisoncwane3412
      @sthembisoncwane3412 6 месяцев назад

      what helped me was to have a image upload tab then convert the image to base64 send it to PHP then use Fpdi library to send the image to pdf

  • @0xjust1
    @0xjust1 4 года назад +1

    thanks a lot dude ! do you know how to import jpg to pdf with pdftk ?

    • @mrdigitalau
      @mrdigitalau  4 года назад

      Hey Justin, what do you want to do? Just add a pdf with an image into it as like a second pdf page? Or include an image onto the page?

    • @0xjust1
      @0xjust1 4 года назад +1

      @@mrdigitalau Thanks for your answer :) I just want to add an image in the pdf, like a field (jpeg_field) but apparently it's impossible to do that with pdftk.I'm looking for a way to include a jpg from the form, without results for the moment :(

    • @0xjust1
      @0xjust1 4 года назад +1

      @@mrdigitalau so, im trying to include an image onto the page ^^

    • @sthembisoncwane3412
      @sthembisoncwane3412 6 месяцев назад

      ​@@0xjust1 what helped me was to have a image upload tab then convert the image to base64 send it to PHP then use Fpdi to send the emage tio pdf

  • @navnitjain
    @navnitjain 4 года назад

    it's working for unicode character?

  • @ChrisRhythmAndVoice
    @ChrisRhythmAndVoice 4 года назад

    How can i input japanese character to the pdf form when generated?

  • @Joselson14
    @Joselson14 4 года назад

    Can I use Atom instead of Visual studio?

    • @mrdigitalau
      @mrdigitalau  4 года назад +1

      Of course mate. Any code editor your wish. As Vasu said, notepad even if you wanted. Would be a bit of a pain though :)

  • @wilsoncalaham5726
    @wilsoncalaham5726 4 года назад

    hi thanx for the great guid , i have a fatal error on the part you use "composer init" here the error i get ibb.co/yN5tzgb , would u please help me? im on centos 7 and using php7 , pdftk server is also installed successfully.

    • @mrdigitalau
      @mrdigitalau  4 года назад

      hi Wilson You need PHP to be installed on your machine. Are you using a web server on your local machine?

  • @mdsafikulislam9113
    @mdsafikulislam9113 4 года назад

    Thank you so much Brother

    • @mrdigitalau
      @mrdigitalau  4 года назад +1

      You're welcome!

    • @happlyfly
      @happlyfly 4 года назад

      Safikul Bhai- could you run the project successfully and yield the expected PDF?

  • @santoshjayswal3905
    @santoshjayswal3905 3 года назад

    the video is great for local server but can you please give us any tip to use it on cpanel server. I find it very hard to install over there. any help would be appreciated

  • @evelsimmon3938
    @evelsimmon3938 3 года назад

    Hi.Thanks for your video.
    I would like to get form fields names and values on my cpanel but I think we can 't use pdftk on cpanel.
    I made a mistake ? or is it possible to use on Cpanel too?
    As possible, please show me some example codes to help me.
    Thank you.

  • @agusnk6732
    @agusnk6732 3 года назад

    Thanks

  • @orlandol6260
    @orlandol6260 4 года назад

    what PC specs u have? seems fast

    • @mrdigitalau
      @mrdigitalau  4 года назад +2

      I've got an Intel i7-8700 3.20 GHz with 32 GB Ram :)

  • @ttaa6371
    @ttaa6371 3 года назад

    the problem of this PDFTK is that you cant use it online on a website. Unless someone knows how to. thanks

    • @mrdigitalau
      @mrdigitalau  3 года назад +1

      Yes you can. You need to install it onto your server. Do you have your own server?

    • @ttaa6371
      @ttaa6371 3 года назад

      @@mrdigitalau no it was on OVH or o2switch where i host my websites

    • @ttaa6371
      @ttaa6371 3 года назад

      i just make a program to add to a CRM i developped but if i cant put it online it was a waist of time !!! So i need help either to find a solution either to find another library doing the same thing

    • @TIFO39
      @TIFO39 8 месяцев назад

      I followed what you've mentioned but still it's not working.
      Im using VPS from hostinger, pdftk installed from centOS 64bit.
      Please any help would be very appreciated.

  • @jovydelfin8933
    @jovydelfin8933 4 года назад

    Is it possible to insert an image?

    • @mrdigitalau
      @mrdigitalau  4 года назад

      As in, attaching an image to the fillable PDF?

    • @jovydelfin8933
      @jovydelfin8933 4 года назад

      @@mrdigitalau Yes. It's a signature that i want to put every time I generate the pdf. Basically the signature was already converted to image that I want to put in the pdf. You think it's possible?

    • @mrdigitalau
      @mrdigitalau  4 года назад

      @@jovydelfin8933 You should put the image into the PDF before it is filled by PHP . If you use adobe acrobat or some other PDF program you should be able to put an image in there.

    • @jovydelfin8933
      @jovydelfin8933 4 года назад

      @@mrdigitalau The signature is different for every record so that's not possible. What I want to achieve is to put signature dynamically same with the fillable fields.

    • @mrdigitalau
      @mrdigitalau  4 года назад

      @@jovydelfin8933 Then you probably can't use a fillable pdf. Try just creating the PDF from scratch with mPDF, then inserting the sig in there as an image. ruclips.net/video/MnIps8Yc8CY/видео.html

  • @osmaloureiro
    @osmaloureiro 2 года назад

    obrigado!

  • @prane81
    @prane81 4 года назад

    what if we donot have adobe pro?

    • @mrdigitalau
      @mrdigitalau  4 года назад +1

      HI Praneet, if you don't have adobe pro - use this in terminal. Run it in the same older the pdf is in. pdftk test.pdf dump_data_fields - it will give you a list of the field names

  • @prane81
    @prane81 4 года назад

    How to use this in live server?

    • @mrdigitalau
      @mrdigitalau  4 года назад +1

      Hi Praneet
      It really depends on what server you are using.. You will need to install PDFTK onto the server itself

    • @artkazun
      @artkazun 3 года назад

      @@mrdigitalau can I just copy the project folder with the installed PDFtk from the localhost to the server?

  • @RamzCompany
    @RamzCompany 4 года назад

    Undefined type 'mikehaertl\pdftk\Pdf'.intelephense(1009) any help all things install perfect

    • @dixon4946
      @dixon4946 2 года назад

      Yo man, did you get anything that fixed this bug for you, cause I'm having the same problem as you were

  • @ArticEditzzz
    @ArticEditzzz 2 года назад

    Stopped your video when you started OOP. I dont know it

    • @mrdigitalau
      @mrdigitalau  Год назад

      Oh mate. You're missing out. What is it about OOP you don't get ? Happy to answer your queries

    • @TIFO39
      @TIFO39 8 месяцев назад

      Hey, I have pdftk installed via centOS on my own VPS (from Hostinger).
      The pdf is never saved in completed file? When I click on download file, open dialog opens but the file is changed to .htm instead of .pdf. After this: nothing is saved