Document Templates preview and PDF generation fail on Zurich — HTML→PDF conversion returns no bytes

Tejas9
Tera Expert

I’m facing an issue on a Zurich family instance with Document Templates and PDF Generation Utilities. Here’s the scenario:

  • In my Yokohama PDI, clicking Preview on an HTML Document Template works fine and generates a PDF.
  • On the client Zurich instance even for OOB records, clicking Preview on the same type of template fails with:
    “Unable to preview document due to an error.”

Troubleshooting Done

  • Verified plugins: Document Templates and PDF Generation Utilities are active.

  • Tried minimal HTML (“Hello World”) in both Document Templates and direct API calls.

  • Used Document Templates API:

 
   new sn_doc.GenerateDocumentAPI().generateDocumentForTask('<record_sys_id>', '<template_sys_id>', 'DocTemplate_Test.pdf');
→ Fails with HTML→PDF conversion error (pdfOS is null).

Tried PDFGenerationAPI smoke test:
var html = '<h1>Hello PDF</h1><p>This is a smoke test.</p>';
new sn_pdfgeneratorutils.PDFGenerationAPI()
  .convertToPDF(html, 'sn_hr_core_case_compensation', '<record_sys_id>', 'HelloSmoke.pdf', '<font_family_sys_id>');

→ Also fails with:

Conversion failed. Cannot invoke "java.io.ByteArrayOutputStream.toByteArray()" because "pdfOS" is null
 

Ask

  • Has anyone seen this pdfOS is null error in Zurich?
  • Is there a known fix or patch for HTML→PDF conversion failures?
  • Any additional configuration needed for Font Families or converter settings?
Any guidance or workaround would be greatly appreciated!
Thanks in advance.
2 REPLIES 2

Ankur Bawiskar
Tera Patron

@Tejas9 

did you try clearing instance cache using cache.do and then logout and login again?

Seems to me like an instance issue as it's OOTB templates.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi @Ankur Bawiskar ,

Thanks for the Response!

By clearing the cache, it not worked .And this issue is not only for OOB records but also custom templates in Zurich release.

Even for just plain text "Hello world", it throws the same error.