Add Signature to PDF Document without Signature field in Node.js using Aspose.PDF REST API

When signing a document using the Node.js NPM PDF SDK, I am trying to digitally sign with .pfx and information that will say the document is from the “company”, etc, but not wanting to add a rectangle, form field with “written” signature, just sign it with certificate. When trying, I am getting error missing formFieldName, etc. Is my requirement something that can be accomplished? And then how to verify?

const signature = new Signature();
        signature.authority = "Linqed-IQ";
        signature.contact = "ppayne@linqed-iq.com"
        signature.date = "08/01/2012 12:15:00.000 PM";
        //signature.formFieldName = "Signature1";
        signature.location = "United States";
        signature.password = "test1234";
        //signature.rectangle = { lLX: 100, lLY: 100, uRX: 500, uRY: 500 };
        signature.signaturePath = "Linqed-IQ.pfx";
        signature.signatureType = SignatureType.PKCS7;
        signature.visible = true;
        signature.showProperties = true;

pdfApi.postSignDocument('ld_signed.pdf', signature, null, remoteFolder).then((result) => {
console.log(result.response);
 }).catch(function(err) {
                        // Deal with an error
                        console.log(err);
                        console.log('SIGN ERROR!');
                    });

Error:
error: Error: cannot POST /v3.0/pdf/ld_signed.pdf/sign?folder=Aspose%20Demo (400)
at Response.toError (/Users/paulpayne/Desktop/velocityS3/SFDC Projects/akg-service-ticket/node_modules/asposepdfcloud/node_modules/superagent/lib/node/response.js:94:15)
at ResponseBase._setStatusProperties (/Users/paulpayne/Desktop/velocityS3/SFDC Projects/akg-service-ticket/node_modules/asposepdfcloud/node_modules/superagent/lib/response-base.js:123:16)
at new Response (/Users/paulpayne/Desktop/velocityS3/SFDC Projects/akg-service-ticket/node_modules/asposepdfcloud/node_modules/superagent/lib/node/response.js:41:8)
at Request._emitResponse (/Users/paulpayne/Desktop/velocityS3/SFDC Projects/akg-service-ticket/node_modules/asposepdfcloud/node_modules/superagent/lib/node/index.js:752:20)
at /Users/paulpayne/Desktop/velocityS3/SFDC Projects/akg-service-ticket/node_modules/asposepdfcloud/node_modules/superagent/lib/node/index.js:916:38
at IncomingMessage. (/Users/paulpayne/Desktop/velocityS3/SFDC Projects/akg-service-ticket/node_modules/asposepdfcloud/node_modules/superagent/lib/node/parsers/json.js:19:7)
at IncomingMessage.emit (events.js:228:7)
at IncomingMessage.EventEmitter.emit (domain.js:475:20)
at endReadableNT (_stream_readable.js:1185:12)
at processTicksAndRejections (internal/process/task_queues.js:81:21) {
status: 400,
text: ‘{“name”:{“ChildNodes”:null,“Children”:null,“Key”:“name”,“SubKey”:{“Buffer”:“name”,“Offset”:0,“Length”:4,“Value”:“name”,“HasValue”:true},“IsContainerNode”:false,“RawValue”:“ld_signed.pdf”,“AttemptedValue”:“ld_signed.pdf”,“Errors”:[],“ValidationState”:2},“folder”:{“ChildNodes”:null,“Children”:null,“Key”:“folder”,“SubKey”:{“Buffer”:“folder”,“Offset”:0,“Length”:6,“Value”:“folder”,“HasValue”:true},“IsContainerNode”:false,“RawValue”:“Aspose Demo”,“AttemptedValue”:“Aspose Demo”,“Errors”:[],“ValidationState”:2},“FormFieldName”:{“ChildNodes”:null,“Children”:null,“Key”:“FormFieldName”,“SubKey”:{“Buffer”:“FormFieldName”,“Offset”:0,“Length”:13,“Value”:“FormFieldName”,“HasValue”:true},“IsContainerNode”:false,“RawValue”:null,“AttemptedValue”:null,“Errors”:[{“Exception”:null,“ErrorMessage”:“FormFieldName must be provided when signing document.”}],“ValidationState”:1}}’,
method: ‘POST’,
path: ‘/v3.0/pdf/ld_signed.pdf/sign?folder=Aspose%20Demo’
},

@ppayneliq

I think you can not sign a PDF document without a form field(signature field). You may set the visible value to false to hide the signature field while passing the signature field name. However, if it does not fulfill your requirement then please share a sample expected output PDF document for reference. You may use Adobe Acrobat/DC to create the sample PDF document. It will help us to understand your requirement and provide the solution accordingly.

The GetVerifySignature API method can be used to verify the signature in PDF document.

Ok, I get the flow now, so I am:

  • Using postSignatureField to create my field
  • Using postSignDocument to digitally sign my document using a .pfx file I created in Adobe DC

Last thing I need is how to verify the document has already been signed and matches/verified against the .pfx file. I only see getVerifySignature, which doesn’t validate against my original cert. How can this be accomplished? This is the same doc I encrypted via my cert that is showing it is valid in Adobe:

(thanks for all the great support btw, close to done w/ all our use cases as we evaluate)

@ppayneliq

We are looking into your requirement and will update you shortly.