Thank you Benjamin for that snippet of code! That was the stuff. : )
For anyone else struggling through this, here's the final code:
Code: Select all
ob_start();
include '../path-to-the/template-you-want/to-convert-to-pdf' ;
require('../scripts/html2pdf/html2fpdf.php'); //obviously the path to the script file
$pdf=new HTML2FPDF();
$pdf->AddPage();
$output = ob_get_clean();
$pdf->WriteHTML($output);
$pdf->Output("C:\Users\your_name\Desktop\sample.pdf"); // path to where you want the output pdf file placed. Desktop is good for starters
echo "PDF file is generated successfully!";
...and for those of you who want to output more than one page/template to the pdf file, you can thank Benjamin for this code:
Code: Select all
// 1st page to include in PDF doc
ob_start();
include '../path-to-the/template-you-want/to-convert-to-pdf' ;
require('../scripts/html2pdf/html2fpdf.php');
$pdf=new HTML2FPDF();
$pdf->AddPage();
$output = ob_get_clean();
$pdf->WriteHTML($output);
// 2nd page to include in PDF doc
ob_start();
include '../path-to-the/template-you-want/to-convert-to-pdf' ;
$pdf->AddPage();
$output = ob_get_clean();
$pdf->WriteHTML($output);
// Seperate this code from above and run only once
$pdf->Output("C:\Users\your_name\Desktop\sample.pdf");
echo "PDF file is generated successfully!";
The code directly above creates ONE pdf with each page on its own separate page. Meaning... you can simply continue adding pages until you've got them all.
Now, when I'm finished making all my pages, I have to figure out how to email it. E-mailing is surprisingly easy I've learned, but just need to figure out the logic of getting this output into an e-mail as an attachment. Not sure if I have to save the doc first and then e-mail or can I go directly to emailing it. I'm sure I can do the latter; just need to figure it out. : )
Thanks again BENJAMIN, but don't go away just yet.

Part II is still to come. lol