Word Wrapping inside table cell is not working in PDFGenerationAPI

Kamal17
Kilo Sage

Hi All,

Scheduled job script (given below) prepares a sample HTML content and uses it to generate a PDF file which then gets attached to that job as an attachment.

var reportContent = "<html><body style=\"background-color:powderblue;\"><style>table, th, td {  border: 1px solid black;  border-collapse: collapse;}td{text-align: left;color: blue;width: 100px;/*word-wrap: break-word;*/word-break: break-all;}th{text-align: center;background-color: blue;color: white;}table { border-collapse: collapse;  table-layout: fixed;  width: 250px;}* {  box-sizing: border-box;}.row {  margin-left:-5px;  margin-right:-5px;}  .column {  float: left;  width: 50%;  padding: 5px;}/* Clearfix (clear floats) */.row::after {  content: \"\";  clear: both;  display: table;}</style><div class =\"row\"><div class=\"column\"><table><tr><th>First Name</th><th>Last Name</th></tr><tr><td>User 1</td><td>S</td></tr><tr><td>User 2 fafdfdfdfdsgfdgfasfhdgsfdasfdgfgsdasfsfdgfddghdreasdfsfdgfgfdsafsgfdghfadfsgdfngsfdafsdftfdfdfdfdsgfdgfasfhdgsfdasfdgfgsdasfsfdgfddghdreasdfsfdgfgfdsafsgfdghfadfsgdfngsfdafsdftergwrhheahhtsrhshbsbhtjhtrgbshrhsfdfdfdfdsgfdgfasfhdgsfdasfdgfgsdasfsfdgfddghdreasdfsfdgfgfdsafsgfdghfadfsgdfngsfdafsdftergwrhheahhtsrhshbsbhtjhtrgbshrhsfdfdfdfdsgfdgfasfhdgsfdasfdgfgsdasfsfdgfddghdreasdfsfdgfgfdsafsgfdghfadfsgdfngsfdafsdftergwrhheahhtsrhshbsbhtjhtrgbshrhsfdfdfdfdsgfdgfasfhdgsfdasfdgfgsdasfsfdgfddghdreasdfsfdgfgfdsafsgfdghfadfsgdfngsfdafsdftergwrhheahhtsrhshbsbhtjhtrgbshrhsfdfdfdfdsgfdgfasfhdgsfdasfdgfgsdasfsfdgfddghdreasdfsfdgfgfdsafsgfdghfadfsgdfngsfdafsdftergwrhheahhtsrhshbsbhtjhtrgbshrhsfdfdfdfdsgfdgfasfhdgsfdasfdgfgsdasfsfdgfddghdreasdfsfdgfgfdsafsgfdghfadfsgdfngsfdafsdftergwrhheahhtsrhshbsbfdfdfdfdsgfdgfasfhdgsfdasfdgfgsdasfsfdgfddghdreasdfsfdgfgfdsafsgfdghfadfsgdfngsfdafsdftergwrhheahhtsrhshbsbhtjhtrgbshrhsfdfdfdfdsgfdgfasfhdgsfdasfdgfgsdasfsfdgfddghdreasdfsfdgfgfdsafsgfdghfadfsgdfngsfdafsdftergwrhheahhtsrhshbsbhtjhtrgbshrhsfdfdfdfdsgfdgfasfhdgsfdasfdgfgsdasfsfdgfddghdreasdfsfdgfgfdsafsgfdghfadfsgdfngsfdafsdftergwrhheahhtsrhshbsbhtjhtrgbshrhshtjhtrgbshrhsergwrhheahhtsrhshbsbhtjhtrgbshrhs</td><td>S</td></tr></table></div><div class=\"column\"><table><tr><th>First Name</th><th>Last Name</th></tr><tr><td>User 1</td><td>S</td></tr><tr><td>User 2</td><td>S</td></tr></table></div></div></body></html>";

var pdfObj = new sn_pdfgeneratorutils.PDFGenerationAPI;
var result = pdfObj.convertToPDF(reportContent,"sysauto_script","056d78132f551110cf55bea62799b6c7","Sample Custom PDF Report");

Issue: When the amount of characters is more in a cell then instead of wrapping the content, it gets overflowed outside the table as highlighted in second screenshot below. No luck even after trying word-wrap: break-word or word-break: break-all in the style attribute.

Expected result:

find_real_file.png

 

Actual result:

find_real_file.png

 

How to ensure the generated PDF applies wrapping when the cell contains larger content?

Thanks!

1 ACCEPTED SOLUTION

Got it, problem is with the underlying ServiceNow instance version. Issue is in Rome version. In San Diego PDF generation works fine and text gets wrapped correctly.

View solution in original post

2 REPLIES 2

Kalaiarasan Pus
Giga Sage

I executed the script provided by and the text does not overflow for me.

Got it, problem is with the underlying ServiceNow instance version. Issue is in Rome version. In San Diego PDF generation works fine and text gets wrapped correctly.