General developer forum

Creating or generating a PDF

 
Raymond
Creating or generating a PDF
 

Hi all,

Is there an easier way, maybe an API somewhere in moodle core, that i can use to create a PDF file, or generate some HTML into PDF format?

Thanks, Ray

 
Average of ratings: -
Davo
Re: Creating or generating a PDF
Core developersParticularly helpful MoodlersPlugin developers

I'm not sure what you mean by 'easier' (compared to what?), but the easiest way I know is:

require_once($CFG->libdir.'/pdflib.php');
$pdf = new pdf();
$pdf->AddPage();
$pdf->WriteHTML('<p>This is an example</p>');
$pdf->Output('mypdf.pdf', 'D');

There is a lot more documentation at: https://tcpdf.org/

(Above written off the top of my head, without testing).


 
Average of ratings: -
Picture of Addison Ervis
Re: Creating or generating a PDF
 

Try using ZedPDF.com

It helped me a lot!


Best regards


Addison Ervis

 
Average of ratings: -