Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Add signature image to fillable PDF

stryker129
Mega Guru

Hi guys,

I've a 'generated_new_unsigned.pdf' file which is attached to sys_user table (for test),

Also I've a signature (activated through Signature Pad plugin) with the following sys_id: 8fa2a193db8003006b2e7b1ebf9619c6

Now I want to add mentioned signature to PDF.

For this purpose I walked through "hr_PdfUtils" script include which comes from HR module plugin.

So, here is my code snippet which doesn't work (sys_id from the last line of code returned as undefined).

var a = new global.GeneralPdfUtils();

var user_table = 'sys_user';

var admin_user_sysid = '6816f79cc0a8016401c5a33be04be441';

var pdf_template_sysid = 'c3d9ce1fdb8003006b2e7b1ebf961943';

var prefilled_pdf_sysid = '146cca9fdbc003006b2e7b1ebf96193a';

var signature_image_sysid = '8fa2a193db8003006b2e7b1ebf9619c6';

var sig = new GlideRecord("signature_image");

sig.get(signature_image_sysid);

var jsonArrayString = '';

var validatorJson = {};

var fl = [];

var mappingInfo = {};

mappingInfo.pageNumber = 0;

mappingInfo.docTop = 30;

mappingInfo.docLeft = 30;

mappingInfo.signTop = 30;

mappingInfo.signLeft = 30;

mappingInfo.boxHeight = 100;

mappingInfo.boxWidth = 100;

mappingInfo.mappingField = "";

fl.push(mappingInfo);

var mappingInfoJson = {};

mappingInfoJson["signatureMapping"] = fl;

mappingInfoJson["dateMapping"] = [];

jsonArrayString = JSON.stringify(mappingInfoJson);

validatorJson.signatureImageSysId = signature_image_sysid;

validatorJson.isAllSignaturesCollected = true;

var jsonStr = JSON.stringify(validatorJson);

var sysid = a.mergeImageToPdf(user_table, admin_user_sysid, jsonArrayString, prefilled_pdf_sysid, 'generated_new_signed.pdf', jsonStr);

Has anyone faced with this before? If so - why 'mergeImageToPdf' method from last line of this code returns undefined? Probably some parameter is wrong?

5 REPLIES 5

Hi there,

Did you eventually get this working? I'm just curious about this and playing around a bit, though unfortunately no documentation and almost no community posts on mergeImageToPdf.

Kind regards,
Mark

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn