Creating ObjectIdentifer in NodeJS

Product: PDFTron SDK for NodeJS

Product Version: 9.4.0

Error with creating ObjectIdentifier instance in NodeJS.

I’m trying to create two instances of ObjectIdentifier, one for digest algorithm, and another for signature algorithm. My goal is to use them to generate CMS signature, which I will use to save custom signature.

I followed the example in the link below:

let digOid = await PDFNet.ObjectIdentifier.createFromIntArray(PDFNet.ObjectIdentifier.Predefined.e_SHA256); let sigOid = await PDFNet.ObjectIdentifier.createFromIntArray(PDFNet.ObjectIdentifier.Predefined.e_RSA_encryption_PKCS1);

However, I’m getting this error:
TypeError: 1st input argument in function 'createFromIntArray' is of type 'number'. Expected type 'Array'.
Which makes sense, because createFromIntArray takes an array as argument, not a number.

I tried wrapping the enum (e.g. PDFNet.ObjectIdentifier.Predefined.e_SHA256) in array like this:
and pass that array as argument, but then I’m getting this error:
{ type: 'PDFWorkerError', message: 'Exception: \n' + '\t Message: OID::encode_into: OID is invalid\n' + '\t Conditional expression: \n' + '\t Version : 9.4.0-29d3f4dfa4\n' + '\t Platform : Windows\n' + '\t Architecture : AMD64\n' + '\t Filename : \n' + '\t Function : \n' + '\t Linenumber : 0\n' }

I also tried creating the instances using createFromPredefined method, and passed the enum as arg, but now I’m getting this error:
{ type: 'MissingCommand', message: 'Unknown Command: objectIdentifierCreateFromPredefined' }

What am I doing wrong here? I did exactly the same thing in the example.

Hello, since you are using the predefined values, please use the following API instead:

okay. that only solves for the digest algorithm OID, what about the signature OID? which method should I use?

I managed to create the OID instance using “createFromIntArray” and passing:
as argument, and it worked!