Looking for instructions on how to setup Terminal > Composer > TCPDF/HTML2PDF

Hi guys, I haven’t used Composer before and I haven’t used the Terminal either. My aim is to use TCPDF (or HTML2PDF) but I am not comfortable with Terminal or Composer and need some very clear guidance.

I did read @sid and @George 's comments in GIT Commit and imported external git project path but it did not help me as a novice in these areas.

I know a few of you have managed to get TCPDF up and running but because it must now be installed through Composer, I feel a bit out of my depth. I have used TCPDF (and HTML2PDF) in previous php projects, but that was a few years ago when you simply downloaded the library files, and before I found out about Wappler.

Can someone help with clear instructions on how to install and setup Composer (using Terminal?) and then install and setup TCPDF or HTML2PDF (they are basically the same thing)?

I really need to get this up and running today. Thanks.

Probably a late reply. I can’t go into detailed explanation, but here is a quick overview (Sorry but I can’t check right now and confirm exact steps):

  1. Install composer
  2. Open terminal in Wappler
  3. Check if “composer” is available (it should be set in PATH environment variables in Windows. No idea abt others)
  4. Run the command as given in the docs (you might have to manually create composer.json file before that)
  5. Once installed, create a example php file which uses the library as a test.
  6. If all is good, set this php to return the response as json… and then refer this php file via API URL in Wappler.

I know its still a bit vague, but this is the best I can come up with as of now.

1 Like

Thanks for your help Sid but it is still too vague for me. I appreciate that you probably don’t have the time, thanks all the same :slight_smile:

If its not too urgent for you, I can try and write up a better example and DM you within this week.

That would really help. As I say, I am getting nowhere fast and need some guidance. I was trying to get a working sample to my client by this evening but that’s not going to happen now. Unfortunately no-one else has come forward with any help and so I would appreciate anything you can do, whenever you can do it.

Cheers

Hi @sid , I managed to install composer and HTML2PDF last night :slight_smile: and I managed to create a basic PDF.

Now for the fun part.

I have tried to do a dynamic PDF but it doesn’t seem to like anything outside of the “page” tag. How can I get it to accept any of the App Connect stuff or Stylesheets?

Hi. I assume you are using spipu/html2pdf library here.
In my use case, I just have PDFs to modify. I do not generate any new PDFs. So I am using TCPDF only.

A quick browse through the documentation suggests that you will have to send the HTML for which you need to generate the PDF.
In case of Wappler, I assume you would like to render something that is on the page (a particular section, sections or complete page), on click of a button.
If this is the case, you need to do two things:

  1. Find some JS which will convert the section/page to a “clean” HTML - meaning all CSS & HTML should be in the string at once.
  2. On click of the button, send that string to a PHP page, where you will pass the input to HTML2PDF object to generate PDF.

Here is a link I found on GitHub which is the source of my understanding: https://github.com/spipu/html2pdf/issues/213

Hi @sid, thanks for your time, I will study your comments and the info in the link you provided.
Cheers