PDF generation not working on some sites but fine on others for custom print templates

White page PDF is generating properly.
It is also generating for the standard (pre-defined ERPNext) templates.
The custom one that I made is working on some sites but not others. Its print preview shows perfectly fine, but PDF gives the mentioned error.