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

ShitalB92986770
Tera Expert

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.
1 ACCEPTED SOLUTION

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.

View solution in original post

3 REPLIES 3

Tanushree Maiti
Tera Patron

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 Accept the solution if it assisted you with your question & Mark this response as Helpful.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti

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.