Excel file convert to PDF
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-12-2023 10:01 AM
How can I automate the conversion of an Excel file to a PDF and include a signature in the PDF document, rather than doing it manually?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-13-2023 04:44 PM
Hello Anila,
There is no feature present in ServiceNow to convert from Excel to PDF After importing into the instance. You can convert Excel to PDF and then you can import it.
we have a Document generation module bys using this functionality we can Generate PDF Excel and doc.
Thanks,
vamsi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-14-2023 02:27 AM
Hi @Anila-21
OOTB it is not available.
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-05-2024 06:10 AM
I have the same problem.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-05-2025 06:28 AM - edited ‎08-05-2025 07:24 AM
Hi Anila-21,
You may try below steps for converting an Excel file to a PDF:
1. Create any server-side script, for eg, a business rule or ui action on the source table where the attachment is attached and use below script:
try {
// Find the most recent attachment on the current record
var grAttach = new GlideRecord('sys_attachment');
grAttach.addQuery('table_sys_id', current.sys_id + '');
grAttach.addQuery('file_name', 'ENDSWITH', '.xlsx').addOrCondition('file_name', 'ENDSWITH', '.xls');
grAttach.orderByDesc('sys_created_on');
grAttach.query();
while (grAttach.next()) {
// Use GlideExcelParser to read the attachment data
var parser = new sn_impex.GlideExcelParser();
var attachment = new GlideSysAttachment();
var attachmentStream = attachment.getContentStream(grAttach.sys_id);
parser.parse(attachmentStream);
// Build the HTML string
var htmlContent = '<table border="1" style="border-collapse: collapse; width: 100%;">';
var headers = parser.getColumnHeaders();
// Add table headers
htmlContent += '<tr style="background-color: #f2f2f2;">';
for (var i = 0; i < headers.length; i++) {
htmlContent += '<th style="padding: 8px;">' + headers[i] + '</th>';
}
htmlContent += '</tr>';
// Add table rows with data
while (parser.next()) {
var row = parser.getRow();
htmlContent += '<tr>';
for (var j = 0; j < headers.length; j++) {
var cellValue = row[headers[j]] || '';
htmlContent += '<td style="padding: 8px;">' + cellValue + '</td>';
}
htmlContent += '</tr>';
}
htmlContent += '</table>';
// Generate the PDF from the HTML field
var pdfName = (grAttach.file_name.toString().indexOf('.xlsx')) ? grAttach.file_name.toString().replace(/\.xlsx?$/, '') + '.pdf' : grAttach.file_name.toString().replace(/\.xls?$/, '') + '.pdf';
var pdfApi = new sn_pdfgeneratorutils.PDFGenerationAPI();
pdfApi.convertToPDF(htmlContent, current.getTableName(), current.sys_id, pdfName);
}
action.setRedirectURL(current);
} catch (e) {
gs.error('Excel to PDF Error: ' + e.message + ' At line: ' + e.lineNumber);
}
I hope this helps anyone in need of any requirement of converting Excel attachment to PDF.
Please like and mark helpful if it helps.
Best Regards,
Amish Ranjan