- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-18-2022 10:18 PM
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:
Actual result:
How to ensure the generated PDF applies wrapping when the cell contains larger content?
Thanks!
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-18-2022 11:02 PM
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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-18-2022 10:47 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-18-2022 11:02 PM
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.