How can I merge three different pdf as one?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2024 09:56 AM
Hi,
I would like to know if we can merge three different pdf files which are attached on an task record to a one single pdf containing the data from all three pdf's?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2024 02:12 AM
Yes, it is possible to merge multiple PDF files attached to a task record into a single PDF in ServiceNow. However, this is not a built-in feature of ServiceNow and would require custom scripting or a third-party integration. Here are the general steps:
1. Retrieve the attachments: Use GlideRecord to query the sys_attachment table and get the attachments associated with the task record.
2. Convert the attachments to a format that can be manipulated: ServiceNow stores attachments as binary data, so you would need to convert this data into a format that can be manipulated, such as a byte array or a stream.
3. Merge the PDFs: This is the most complex step and would likely require a third-party library or API. There are many libraries available for manipulating PDFs, such as PDFBox or iText. You would need to write a script that uses one of these libraries to merge the PDFs.
4. Attach the merged PDF to the task record: Once the PDFs have been merged, you can convert the merged PDF back into binary data and attach it to the task record using the Attachment API.
Here is a sample code:
javascript
var gr = new GlideRecord('sys_attachment');
gr.addQuery('table_sys_id', taskSysId);
gr.addQuery('table_name', 'task');
gr.query();
while(gr.next()) {
var sa = new GlideSysAttachment();
var bytes = sa.getBytes(gr);
// Use a third-party library to merge the PDFs
}
// Use the Attachment API to attach the merged PDF to the task record
var attachment = new GlideSysAttachment();
attachment.write(taskGr, 'merged.pdf', 'application/pdf', mergedBytes);
Please note that this is a high-level overview and the actual implementation may vary depending on the specific requirements and the third-party library used.
nowKB.com
For a good and optimistic result, and solving ServiceNow-related issues please visit this website.https://nowkb.com/home
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2024 01:14 PM
Hey @sashraf93 ! Have you ever solve this ?
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2024 03:20 AM
Hi Everyone,
I was trying to include pdfbox external library in ServiceNow UI page to merge multiple pdf's. How can we call the mergerutility function from the library in ServiceNow
