Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

Document is not getting generated after preview

CaptainG
Tera Contributor

Hello team,

 

I have selected document template and after preview i am getting below error and logs. Can someone please help with this. Its for ootb document template and as well as custom document template.
Error:

CaptainG_0-1775064900231.jpeg

 

Logs:

Request : <sysid> failed with ' Conversion failed. Cannot invoke "java.io.ByteArrayOutputStream.toByteArray()" because "pdfOS" is null': no thrown error

8 REPLIES 8

pr8172510
Giga Guru

Hi CaptainG,

 

1. Understanding the error

Error:

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

This means:

  • The PDF engine failed to generate output
  • So the stream (pdfOS) was never initialized

2. Why this happens (most common causes)

 1. Missing / misconfigured PDF Generation Plugin

Check if required plugins are active:

  • Document Generation
  • PDF Generation (iText / DocGen related plugins)

Sometimes after upgrades or changes, dependencies break


 2. HTML in template is not valid

Even for OOTB templates, if you modified:

  • HTML structure
  • CSS
  • Embedded scripts

It can break PDF rendering

Things to check:

  • Unclosed tags
  • Unsupported CSS
  • Images / external references

3. Fonts / attachments issue

If template uses:

  • Custom fonts
  • Images

 And system cannot access them → PDF fails silently


4. Instance-level issue (very common)

This error is often seen when:

  • PDF generation service is not responding properly
  • Node/cache issue

Try:

  • cache.do
  • Switch node (if multi-node instance)

5. Template context / data issue

If preview works partially but fails on generate:

  • Check:
    • Fields used in template
    • Null/invalid data

3. Quick validation steps

Try these to isolate:

  1. Use completely OOTB template (no changes)
  2. Generate for a simple record
  3. Check:
    • Same error or not

 If still failing → platform issue
 If not → template issue

Hi @pr8172510 ,

I have verified all the things, its completely OOTB template but still failing.

Tanushree Maiti
Kilo Patron

Hi @CaptainG 

 

Can you confirm whether your document template is published

 

 

Please mark this response as Helpful & Accept it as solution if it assisted you with your question.
Regards
Tanushree Maiti
ServiceNow Technical Architect
Linkedin:

Hi @Tanushree Maiti ,

Its published and its completely ootb template but still facing issue.