I feel so lucky getting these kind responses, @Maddy_Mathan, @sitestreet, @NewMedia!
Thanks
After some fiddling with the content of @Maddy_Mathan’s comment and googling some php-basics (that I am clearly lacking) I got it going, thanks guys!
So for fellow Bubble user getting into Wappler or other Wappler users that could categorize themselves as novice; here is a small writeup of how to batch create pdfs using FPDF with Wappler:
1: Download FPDF for php (in this case) and copy complete folder to your wappler project folder. Create a new pdf folder within that folder that will contain your code to create the pdf (more on this in later step).
2: Go to server actions, add a new action and Setup a Query that returns the data you want, as a first step. I suggest to start with a paged query so you can easily control the number of rows returned with the LIMIT param.
3: add a repeat with an API action as a step. Use POST as method, data type FORM and add the data you want to use or display for your pdf as Input Data. It took me a while to figure out how to point to the actual php file. In my case I am running a project in docker on a localhost. So the url would be: http://localhost/fpdf183/filename.php (insert your filename) Here is a screenshot with some example:
4: Edit your php file in your fpdf folder (I use Visual Studio Code) and paste this code to get a working minimum:
<?php
// Get variables from form post
$name= isset($_POST['name']) ? $_POST['name'] : "";
// you can use this next line to check if the variable gets through:
//echo "naam: ".$name;
require('/var/www/html/php_libs/fpdf183/fpdf.php');
//A4 width : 219mm
//default margin : 10mm each side
//writable horizontal : 219-(10*2)=189mm
$pdf = new FPDF('P','mm','A4');
$pdf->AddPage();
$pdf->SetFont('Helvetica','',12);
$pdf->Cell(47,10,$name,1,0);
$pdf->Output('../'.$name. '.pdf', 'F');
?>
Save file
5: right click your server action file in Wappler and click run in browser.
6:
Voila your pdf’s will be generated in your wappler project folder!
Thanks again guys.
@NewMedia I will surely get into file name part now, like you suggested. For now I’m super stoked that the pdf’s actually generate!