Generate Custom PDFs
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-24-2025 11:28 PM
Var PDF_Name = "Custom PDF";
var pdfObj = new sn_pdfgeneratorutils.PDFGenerationAPI();
var result = pdfObj.convertToPDF('HTML_string', '<table_name>','<record_sys_id>',<PDF_Name>);
2 REPLIES 2
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-25-2025 12:03 AM
var PDF_Name = "Custom_PDF_Name.pdf"; // Must end with .pdf
var pdfAPI = new sn_pdfgeneratorutils.PDFGenerationAPI();
// Your HTML string for the PDF content
var htmlContent = "<html><body><h1>Hello from PDF!</h1><p>This is a custom PDF document.</p></body></html>";
// Call convertToPDF()
var result = pdfAPI.convertToPDF(htmlContent, 'incident', 'incident sys_id', PDF_Name);
// Handle the result
if (result.getStatus() === 'success') {
var sysId = result.getDocumentId(); // sys_id of the generated PDF (sys_attachment)
gs.info("PDF generated successfully. Attachment sys_id: " + sysId);
} else {
gs.error("PDF generation failed: " + result.getErrorMessage());
}
Please mark my answer as helpful/correct if it resolves your query.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-25-2025 12:18 AM
what's your business requirement and what's your question?
Regards,
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader