Get a first look at what's coming. The Developer Passport Australia Release Preview kicks off March 12. Dive in! 

Error Message: Cannot invoke "java.io.ByteArrayOutputStream.toByteArray()" because "pdfOS" is null

ShitalB92986770
Tera Contributor

HI Team,

 

While generating PDF in Plan in BCM, i am getting "Error: Unable to generate PDF attachment".

When i dig into the code level, i found that error is coming from -

 var pdfGenerationAPI = new sn_pdfgeneratorutils.PDFGenerationAPI();
var response = pdfGenerationAPI.convertToPDFWithHeaderFooter(
        params.htmlBody,
        params.targetTable,
        params.targetSysId,
        params.generatedPdfName,
        _getHeaderFooterInfo(params.htmlTemplateGr),
        params.htmlTemplateGr.custom_font.toString(),
        documentConfiguration
    );
 
response is -  {"message":" Conversion failed. HTML to PDF conversion has failed with exception : Index 1 out of bounds for length 1","request_id":"***************************************","status":"failure"}
 
It's happening only for one record. I already tried by cleating cache on instance and on browser level.
Please let me know if anyone has any idea on this.
Thank you.
3 REPLIES 3

Tanushree Maiti
Tera Sage

Hi ,

First go to All document template -> open your template which is generating pdf and confirm it is published

If it is not published, make it Publish 

And confirm here what result you are getting.

 

 

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, it is in published state already and then today suddenly PDF got generated.

strange behavior..i guess when i cleared cache it took time..maybe 

HI, i just found out that issue still exists.

It is causing due to CSS added as below - 

<style>

@page {size: landscape}

</style>

 

If i remove this from Document Template, then PDF is getting generated correctly.

Can anyone please help how to add landscape css to resolve this issue? 

Thank you.