- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2025 12:37 AM
I have an attach a pdf in my incident form . I want the total number of pages in the pdf without using any third party api. Tell me a background script for that or any other way . I want to show an alert box in my incident form which shows number of pages of the attachment attached to it
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2025 12:44 AM
Please use the following Script:
var desc;
var att = new GlideRecord('sys_attachment');
att.get("373535a1878eee10778e43b90cbb3593"); //Replace this with sys_id of your attached document,
att.query();
if (att.next()) {
var sa = new GlideSysAttachment();
var binData = sa.getBytes(att);
var v = new sn_pdfgeneratorutils.PDFGenerationAPI;
var result = v.getPdfPageSizes(att.sys_id);
var page_count = 0;
for (k in result.pages_size) {
if (result.pages_size.hasOwnProperty(k)) ++page_count;
}
gs.info(page_count);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2025 12:47 AM
Hi @Prajusha
The only option I could think of is Document Intelligence if you don't want to consume any third-party APIs. https://www.servicenow.com/docs/bundle/yokohama-intelligent-experiences/page/administer/document-int...
Thanks & Regards
Amit Verma
Please mark this response as correct and helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2025 03:24 AM
tell me how
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2025 12:44 AM
Please use the following Script:
var desc;
var att = new GlideRecord('sys_attachment');
att.get("373535a1878eee10778e43b90cbb3593"); //Replace this with sys_id of your attached document,
att.query();
if (att.next()) {
var sa = new GlideSysAttachment();
var binData = sa.getBytes(att);
var v = new sn_pdfgeneratorutils.PDFGenerationAPI;
var result = v.getPdfPageSizes(att.sys_id);
var page_count = 0;
for (k in result.pages_size) {
if (result.pages_size.hasOwnProperty(k)) ++page_count;
}
gs.info(page_count);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2025 12:46 AM
try the script shared by @gauravmudgal and see if that works
If not then you cannot use any OOTB method or class for this.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader