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?
I'm not sure what you mean by 'easier' (compared to what?), but the easiest way I know is:
$pdf = new pdf();
$pdf->WriteHTML('<p>This is an example</p>');
There is a lot more documentation at: https://tcpdf.org/
(Above written off the top of my head, without testing).
Try using ZedPDF.com
It helped me a lot!