Merge multiple PDF Attachments

kalyani8
Giga Expert

Hi,

We are trying to combine multiple PDf'S from a table record to ONE PDF, we tried using the OOB PDF generator but it didn't work as we are not sure what parameters need to be passed on. We also tried multiple approaches like attachment API, GlideSysAttachment, encode decode GlideStringUtil, base64.

 

Thanks in advance !

 

9 REPLIES 9

Jace Benson
Mega Sage

I don't think SN natively has the ability to do this.  It would probably be possible to do it on a midserver with some python or nodejs.  Seems like a difficult requirement.  What does combining these files save your business?

Hi ,

 

The client uses some third  party tool which accepts only PDF file. The records may contain multiple files, but at the end they want a single PDF at one place, so that they can upload in their tool and reduce the man power to find files and upload manually.

This is the requirement we have .

Kindly suggest any approach.

 

Regards,

Kalyani

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Kalyani,

I don't think out of the box this is present

Are you saying that you have 3 pdf files and want to merge those 3 into 1 and then attach again to the same record

what is your exact requirement here?

you will have to do something custom for this.

Regards

Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Kalyani,

have this approach:

1) set up a mid server

2) create mid server script include and function

3) that function will accept base64encoded data of those 2 files

4) java code will merge that and return the combined base64encoded data

5) write an after insert business rule on ecc_queue that will create an attachment using Attachment Creator

var fileName = 'merged1';

var contentType = 'application/pdf';

var tableName = 'incident'; // for example purpose

var tableSysId = 'bdd212d04fbf7340fc11fa218110c7d5'; // incident record sys_id

// you need to parse the ecc_queue payload field and then pick the combinedBase64EncodedData

var content = 'combinedBase64EncodedData'; 

gs.info("content is " + content);

var eccGr = new GlideRecord('ecc_queue');

eccGr.initialize();

eccGr.setValue('agent', 'AttachmentCreator');

eccGr.setValue('topic', 'AttachmentCreator');

eccGr.setValue('name', fileName + ':' + contentType);

eccGr.setValue('source', tableName + ':' + tableSysId);

eccGr.setValue('payload', content);

eccGr.insert();

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader