You might be underestimating how complex it is to build a html to pdf renderer from scratch. If you need one from scratch, it would take a single programmer many years to develop.
I would recommending starting from dompdf
or using casperjs
to take screenshots and convert the png files to PDF files using Image Magick.