Table of Content automatic generation
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2022 08:04 AM
Hi all,
I've received the requirement to include in the Audit Report also a table of content to be automatically inserted with indication of paragraphs and related page where those starts.
Anyone knows if there is a way to do so?
I found out this API (PDFGenerationAPI) that when generating a PDF starting from the Knowledge Article, it should automatically insert a Table of Content, but i'm not able to make this work (the method i'm currently using is "convertToPDFWithHeaderFooter", which also allows me to include headers and footers in the generated PDF).
Following the test code i'm currently using via background script to try to better understand how it can be coded:
var v = new sn_pdfgeneratorutils.PDFGenerationAPI;
var htmlBody = '<style> table, tr, th { padding: 5px 10px 5px 0px; margin-top:20px; } .engagement_table td { padding-top: 0px; padding-bottom: 15px; } .relatedlist_table { width: 100%; } .relatedlist_table tr, .relatedlist_table td, .relatedlist_table th{ padding: 5px 10px 5px 10px; border: 1px solid #BDC3C7; } .relatedlist_table td, .relatedlist_table th{ width: 25%; height: 100%; } th { background-color: #e7e9eb; font-size: 14px; } li { padding-left: 20px; } div { min-height: 17px; } </style><table class="engagement_table" style="width: 100%;"><tbody><sn-toc>text</sn-toc><p>FIRST PARAGRAPH</p><tr><th>Name</th></tr><tr><td>IT Operations Review Q2 - Italy - Plant</td></tr><tr><th>Description</th></tr><tr><td>Review how the IT Department operates as well as inspect the facilities and data centers IT manages.</td></tr><tr><th>Scope</th></tr><tr><td style="padding-bottom: 5px;">The scope of the audit includes:</td></tr><tr><td> </td></tr></tbody></table><ul><li>SAP Materials Management</li></ul><p>ObjectivesverificatoResults<br /><p style="page-break-after: always;"> </p><p style="page-break-before: always;"> </p>Summary of issues</p><table class="relatedlist_table"><tbody><tr><th colspan="4">Issue IPT0020092</th></tr><tr><th>Short Description</th><td colspan="3"><div> </div></td></tr><tr><th colspan="4">Description</th></tr><tr><td colspan="4"> </td></tr><tr><th colspan="4">Recommendation</th></tr><tr><td colspan="4"><div> </div></td></tr><tr><th colspan="4">Action Plan</th></tr><tr><th>Assigned to</th><td> </td><td> </td><td> </td></tr><tr><th>Response</th><td> </td><th>Planned End Date</th><td>2022-09-24 13:59:42</td></tr><tr><th colspan="4">Explanation</th></tr><tr><td colspan="4"><div> </div></td></tr></tbody></table><p>SECOND PARAGRAPH</p>TEST Test TEST Test TEST Test TEST Test TEST Test TEST Test TEST Test TEST Test TEST Test TEST Test TEST Test TEST Test TEST Test TEST Test TEST Test TEST Test TEST Test TEST Test TEST Test TEST Test TEST Test TEST Test TEST Test TEST Test TEST Test TEST Test TEST Test TEST Test <br>TEST Test TEST Test TEST Test TEST Test TEST Test TEST Test TEST Test TEST Test TEST Test TEST Test TEST Test TEST Test TEST Test TEST Test TEST Test TEST Test TEST Test TEST Test TEST Test <br>TEST Test TEST Test TEST Test TEST Test TEST Test TEST Test TEST Test <br>TEST Test TEST Test TEST Test TEST Test TEST Test TEST Test <br>' ;
var styleHtml = '<style>'+
'@page {' +
'size: A4 portrait;' +
'margin-left: 1cm;' +
'margin-top: 1cm;' +
'margin-right: 1cm;' +
'margin-bottom: 1cm;' +
'@bottom-right { content: "Page " counter(page) " of " counter(pages); font-size:8pt; }' +
'}' + '</style>';
var html = styleHtml + htmlBody;
var hfInfo = new Object();
hfInfo["FooterText"] = "Sample Footer Message";
hfInfo["PageSize"] = "A4";
hfInfo["GeneratePageNumber"] = "false";
hfInfo["TopOrBottomMargin"] = "36";
hfInfo["LeftOrRightMargin"] = "24";
var docConfig = {
"documentConfiguration": {
"toc_config" : "ef843c91c7023010da58d25827c2605c",
"page_number_config" : "afd4fc91c7023010da58d25827c26092"
}
};
var font = "f0bac6652f4111100328b8e72799b609";
var result = v.convertToPDFWithHeaderFooter(html, "sn_audit_engagement", "36a5c04713a0120061fdb3173244b01b", new GlideDateTime() + " PDF", hfInfo, font, docConfig);
gs.info(JSON.stringify(result));
Does anyone knows how can i achieve this?
Thanks,
Daniele
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2023 02:22 PM
Try adding this to your HTML.