Some rows are not fetched while generating pdf

It looks like you’re rendering the entire document as a string and then writing that string to a pdf.

Have you tried writing html to a file and visually verifying that that is correct? (I think the next thing to check would be the template.)