### Install dependencies for ZGapdfsigner Source: https://github.com/zboris12/zgapdfsigner/blob/main/README.md List of required npm packages: pdf-lib, node-forge, follow-redirects, pako, and pdf-fontkit. pako is used for drawing text. ```markdown * [pdf-lib](https://pdf-lib.js.org/) * [node-forge](https://github.com/digitalbazaar/forge) * [follow-redirects](https://github.com/follow-redirects/follow-redirects) * [pako](https://github.com/nodeca/pako) - For drawing text * [pdf-fontkit](https://github.com/znacloud/pdf-fontkit) ``` -------------------------------- ### getToken(forP7) Source: https://github.com/zboris12/zgapdfsigner/wiki/API Gets the token data from the TSA response, optionally formatted for appending to a PKCS#7 signature. ```APIDOC ## getToken(forP7) ### Description Get the token data in response from TSA. ### Method getToken ### Parameters - **forP7** (boolean) - Optional - To create an asn1 for appending to a pkcs#7 signature or not. ### Returns - **forge.asn1** - The token data. ``` -------------------------------- ### getEmbeddedFont(fontData, subset) Source: https://github.com/zboris12/zgapdfsigner/wiki/API Gets an embedded font from the PDF document, or creates one if it does not exist. ```APIDOC ## getEmbeddedFont(fontData, subset) ### Description Get the embedded font or create one if not exists. ### Method getEmbeddedFont ### Parameters - **fontData** (Array | Uint8Array | ArrayBuffer | PDFLib.StandardFonts) - Optional - Data of font. If omitted, the default font is `PDFLib.StandardFonts.Helvetica` if there is no existing embedded font. Or the default font is the first existing embedded font. - **subset** (boolean) - Optional - Create font subset or not. ### Returns - **Promise** - A promise that resolves to the embedded font. ``` -------------------------------- ### new PdfSigner(signopt) Source: https://github.com/zboris12/zgapdfsigner/wiki/API Creates a new PdfSigner instance with signing options. ```APIDOC ## Constructor: new PdfSigner(signopt) ### Description Creates a new PdfSigner instance with the provided signing options. ### Parameters - **signopt** (SignOption) - Required - Information of signing. ``` -------------------------------- ### CertsChain.getSignCert() Source: https://github.com/zboris12/zgapdfsigner/wiki/API Returns the certificate for signing. ```APIDOC ## CertsChain.getSignCert() ### Description Returns the certificate for signing. ### Method Function ### Signature getSignCert() :arrow_right: forge.pki.Certificate ### Returns - **forge.pki.Certificate** - The certificate for signing. ``` -------------------------------- ### sign(pdf, cypopt?) Source: https://github.com/zboris12/zgapdfsigner/wiki/API Signs the PDF and returns the binary data. ```APIDOC ## Method: sign(pdf, cypopt?) ### Description Signs the PDF and returns the binary data. ### Parameters - **pdf** (PDFLib.PDFDocument | Array | Uint8Array | ArrayBuffer | string) - Required - The target PDF. - **cypopt** (EncryptOption) - Optional - The information of encryption. ### Returns - **Promise** - The signed PDF binary data. ``` -------------------------------- ### SignOption Source: https://github.com/zboris12/zgapdfsigner/wiki/API Configuration object for PDF signing. It specifies the certificate, password, permissions, signature details, timestamping, and LTV settings. ```APIDOC ## SignOption ### Description Configuration object for PDF signing. It specifies the certificate, password, permissions, signature details, timestamping, and LTV settings. ### Fields | Name | Type | Attributes | Description | | --- | --- | --- | --- | | p12cert | Array / Uint8Array / ArrayBuffer / string | optional | Certificate's data. In the case of adding a document timestamp, it must be omitted. | | pwd | string | optional | The passphrase of the certificate. In the case of adding a document timestamp, it must be omitted. | | permission | number | optional | The modification permissions granted for this document. Valid values: 1 (no changes), 2 (form filling, page templates, signing), 3 (same as 2 plus annotation creation/deletion/modification). | | reason | string | optional | The reason for signing. | | location | string | optional | Your location. | | contact | string | optional | Your contact information. | | signdate | TsaServiceInfo / string / Date | optional | In the case of adding a document timestamp, it can't be omitted and can't be a Date. When a Date, it is the signing date/time. When a string, it can be a TSA URL or preset index (1-7). When a TsaServiceInfo, it is a full customized TSA. When omitted, system timestamp is used. | | signame | string | optional | The name of the signature. | | drawinf | SignDrawInfo | optional | Visible signature's information. | | ltv | number | optional | The method of how to enable LTV. Valid values: 1 (auto: try OCSP then CRL), 2 (CRL only). | | debug | boolean | optional | To output debug information or not. | ``` -------------------------------- ### CertsChain.getAllCerts() Source: https://github.com/zboris12/zgapdfsigner/wiki/API Returns an array of all certificates in the chain. ```APIDOC ## CertsChain.getAllCerts() ### Description Returns an array of all certificates in the chain. ### Method Function ### Signature getAllCerts() :arrow_right: Array ### Returns - **Array** - An array of all certificates. ``` -------------------------------- ### CertsChain.prepareDSSInf(crlOnly) Source: https://github.com/zboris12/zgapdfsigner/wiki/API Returns the informations of DSS (Digital Signature Service). Optionally queries CRL only or tries OCSP first. ```APIDOC ## CertsChain.prepareDSSInf(crlOnly) ### Description Returns the informations of DSS (Digital Signature Service). Optionally queries CRL only or tries OCSP first. ### Method Function ### Signature prepareDSSInf(crlOnly) :arrow_right: Promise ### Parameters - **crlOnly** (boolean) - Optional - Query CRL only or try query OCSP first. ### Returns - **Promise** - A promise that resolves to the DSS information. ``` -------------------------------- ### new CertsChain(certs) Source: https://github.com/zboris12/zgapdfsigner/wiki/API Constructor for the CertsChain class. Initializes a certificate chain with an optional array of certificates. ```APIDOC ## new CertsChain(certs) ### Description Constructor for the CertsChain class. Initializes a certificate chain with an optional array of certificates. ### Method Constructor ### Parameters - **certs** (Array | Array | Array) - Optional - An array of certificates. ``` -------------------------------- ### new PdfCryptor(encopt) Source: https://github.com/zboris12/zgapdfsigner/wiki/API Creates a new PdfCryptor instance with encryption options. ```APIDOC ## Constructor: new PdfCryptor(encopt) ### Description Creates a new PdfCryptor instance with the provided encryption options. ### Parameters - **encopt** (EncryptOption) - Required - Information of encryption. ``` -------------------------------- ### Sign PDF with strictCrypto enabled (Zga.PdfSigner) Source: https://github.com/zboris12/zgapdfsigner/blob/main/README.md Sets strictCrypto: true on the SignOption so the signer rejects anything CCN-STIC-221 does not authorize. Only AES-256 encryption is accepted; any other mode throws. The flag on the SignOption also applies to the encryption step. ```javascript var sopt = { p12cert: cert, pwd: pwd, strictCrypto: true, }; var eopt = { mode: Zga.Crypto.Mode.AES_256, // anything else throws under strictCrypto userpwd: upwd, }; // strictCrypto on the SignOption also applies to the encryption step. var u8arr = await new Zga.PdfSigner(sopt).sign(pdf, eopt); ``` -------------------------------- ### CertsChain.buildChain(cert) Source: https://github.com/zboris12/zgapdfsigner/wiki/API Builds the certificates chain from the specified certificate, and returns true if this operation is successful. ```APIDOC ## CertsChain.buildChain(cert) ### Description Builds the certificates chain from the specified certificate, and returns true if this operation is successful. ### Method Function ### Signature buildChain(cert) :arrow_right: Promise ### Parameters - **cert** (forge.pki.Certificate) - Required - A certificate to start build by looking for it's issuer. ### Returns - **Promise** - A promise that resolves to true if the chain was built successfully. ``` -------------------------------- ### Sign PDF with PFX certificate in Node.js Source: https://github.com/zboris12/zgapdfsigner/blob/main/README.md Use this snippet to sign a PDF file with a PFX certificate in Node.js. It reads the PDF, PFX, image, and font files from disk, and accepts the PFX path and passphrase as command-line arguments. If no passphrase is provided, the PFX path is cleared and the signature is created without a certificate. ```js const m_fs = require("fs"); const m_path = require("path"); async function main(){ /** @type {string} */ var pdfPath = m_path.join(__dirname, "_test.pdf"); /** @type {string} */ var pfxPath = m_path.join(__dirname, "_test.pfx"); /** @type {string} */ var ps = ""; /** @type {string} */ var imgPath = m_path.join(__dirname, "_test.png"); /** @type {string} */ var txt = "I am a test string!"; /** @type {string} */ var fontPath = m_path.join(__dirname, "_test.ttf"); if(process.argv.length > 3){ pfxPath = process.argv[2]; ps = process.argv[3]; }else if(process.argv[2]){ ps = process.argv[2]; } if(!ps){ // throw new Error( ``` ```js const m_fs = require("fs"); const m_path = require("path"); async function main(){ /** @type {string} */ var pdfPath = m_path.join(__dirname, "_test.pdf"); /** @type {string} */ var pfxPath = m_path.join(__dirname, "_test.pfx"); /** @type {string} */ var ps = ""; /** @type {string} */ var imgPath = m_path.join(__dirname, "_test.png"); /** @type {string} */ var txt = "I am a test string!"; /** @type {string} */ var fontPath = m_path.join(__dirname, "_test.ttf"); if(process.argv.length > 3){ pfxPath = process.argv[2]; ps = process.argv[3]; }else if(process.argv[2]){ ps = process.argv[2]; } if(!ps){ // throw new Error("The passphrase is not specified."); pfxPath = ""; } /** @type {Buffer} */ var pdf = m_fs.readFileSync(pdfPath); /** @type {Buffer} */ var pfx = null; if(pfxPath){ pfx = m_fs.readFileSync(pfxPath); } /** @type {Buffer} */ var img = null; /** @type {Buffer} */ var img = null; /** @type {Buffer} */ var img = null; /** @type {Buffer} */ var img = null; /** @type {Buffer} */ var img = null; /** @type {Buffer} */ var img = null; /** @type {Buffer} */ var img = null; /** @type {Buffer} */ var img = null; /** @type {Buffer} */ var img = null; /** @type {Buffer} */ var img = null; /** @type {Buffer} */ var img = null; /** @type {Buffer} */ var img = null; /** @type {Buffer} */ var img = null; /** @type {Buffer} */ var img = null; /** @type {Buffer} */ var img = null; /** @type {Buffer} */ var img = null; /** @type {Buffer} */ var img = null; /** @type {Buffer} */ var img = null; /** @type {Buffer} */ var img = null; /** @type {Buffer} */ var img = null; /** @type {Buffer} */ var img = null; /** @type {Buffer} */ var img = null; /** @type {Buffer} */ var img = null; /** @type {Buffer} */ var img = null; /** @type {Buffer} */ var img = null; /** @type {Buffer} */ var img = null; /** @type {Buffer} */ var img = null; /** @type {Buffer} */ var img = null; /** @type {Buffer} */ var img = null; /** @type {Buffer} */ var img = null; /** @type {Buffer} */ var img = null; /** @type {Buffer} */ var img = null; /** @type {Buffer} */ var img = null; /** @type {Buffer} */ var img = null; /** @type {Buffer} */ var img = null; /** @type {Buffer} */ var img = null; /** @type {Buffer} */ var img = null; /** @type {Buffer} */ var img = null; /** @type {Buffer} */ var img = null; /** @type {Buffer} */ var img = null; /** @type {Buffer} */ var img = null; /** @type {Buffer} */ var img = null; /** @type {Buffer} */ var img = null; /** @type {Buffer} */ var img = null; /** @type {Buffer} */ var img = null; /** @type {Buffer} */ var img = null; /** @type {Buffer} */ var img = null; /** @ ``` -------------------------------- ### Sign PDF with invisible signature using Zga.PdfSigner Source: https://github.com/zboris12/zgapdfsigner/blob/main/README.md Signs a PDF with an invisible signature. Requires a PDF ArrayBuffer, a PKCS#12 certificate ArrayBuffer, and the certificate password. Returns a Promise resolving to a Blob of type application/pdf. ```js /** * @param {ArrayBuffer} pdf * @param {ArrayBuffer} cert * @param {string} pwd * @return {Promise} */ async function sign1(pdf, cert, pwd){ /** @type {SignOption} */ var sopt = { p12cert: cert, pwd: pwd, permission: 1, }; var signer = new Zga.PdfSigner(sopt); var u8arr = await signer.sign(pdf); return new Blob([u8arr], { ``` ```js type": "application/pdf"}); } ``` -------------------------------- ### encryptPdf(pdf, ref?) Source: https://github.com/zboris12/zgapdfsigner/wiki/API Encrypts the contents in the PDF and returns the PDF document. ```APIDOC ## Method: encryptPdf(pdf, ref?) ### Description Encrypts the contents in the PDF and returns the PDF document. ### Parameters - **pdf** (PDFLib.PDFDocument | Array | Uint8Array | ArrayBuffer | string) - Required - The target PDF. - **ref** (PDFLib.PDFRef) - Optional - The unique reference will be assigned to the encryption information. ### Returns - **Promise** - The encrypted PDF document. ``` -------------------------------- ### protect1: Set password protection on a PDF with Zga.PdfCryptor Source: https://github.com/zboris12/zgapdfsigner/blob/main/README.md Encrypts a PDF with a user and owner password using RC4_40 mode and a set of permissions. Returns a Blob with the protected PDF. Requires an ArrayBuffer of the PDF and two password strings. ```js /** * @param {ArrayBuffer} pdf * @param {string} upwd * @param {string} opwd * @return {Promise} */ async function protect1(pdf, upwd, opwd){ /** @type {EncryptOption} */ var eopt = { mode: Zga.Crypto.Mode.RC4_40, permissions: [ ``` -------------------------------- ### new TsaFetcher(inf) Source: https://github.com/zboris12/zgapdfsigner/wiki/API Creates a new TsaFetcher instance with the provided TSA service information. ```APIDOC ## new TsaFetcher(inf) ### Description Creates a new TsaFetcher instance with the provided TSA service information. ### Method Constructor ### Parameters - **inf** (TsaServiceInfo) - Required - Information of TSA. ### Properties - **url** (string) - The url of TSA. - **len** (number) - The length of signature generated by the TSA. ``` -------------------------------- ### getCertsChain() Source: https://github.com/zboris12/zgapdfsigner/wiki/API Retrieves the certificates' chain from the response of the TSA. ```APIDOC ## getCertsChain() ### Description Get the certificates' chain from the response of TSA. ### Method getCertsChain ### Returns - **CertsChain** - The certificates' chain. ``` -------------------------------- ### protect2 - Set public-key certificate protection to the PDF Source: https://github.com/zboris12/zgapdfsigner/blob/main/README.md Encrypts a PDF with public-key certificate protection using AES_128 encryption mode and specified permissions. ```APIDOC ## protect2(pdf, cert) ### Description Sets public-key certificate protection to the PDF using AES_128 encryption mode. ### Method Function call ### Parameters - **pdf** (ArrayBuffer) - Required - The PDF file as an ArrayBuffer. - **cert** (ArrayBuffer) - Required - The certificate used for encryption. ### Request Example ```js async function protect2(pdf, cert){ /** @type {EncryptOption} */ var eopt = { mode: Zga.Crypto.Mode.AES_128, pubkeys: [{ c: cert, p: ["copy", "modify", "copy-extract", "annot-forms", "fill-forms", "extract", "assemble"], }], }; var cyptor = new Zga.PdfCryptor(eopt); var pdfdoc = await cyptor.encryptPdf(pdf); u8arr = await pdfdoc.save({"useObjectStreams": false}); return new Blob([u8arr], {"type" : "application/pdf"}); } ``` ``` -------------------------------- ### protect2 - Set public-key certificate protection to the PDF Source: https://github.com/zboris12/zgapdfsigner/blob/main/README.md Encrypts a PDF with public-key certificate protection using AES_128 encryption mode and specified permissions. ```APIDOC ## protect2(pdf, cert) ### Description Sets public-key certificate protection to the PDF using AES_128 encryption mode. ### Method Function call ### Parameters - **pdf** (ArrayBuffer) - Required - The PDF file content as an ArrayBuffer. - **cert** (ArrayBuffer) - Required - The certificate used for encryption. ### Request Example ```js async function protect2(pdf, cert){ /** @type {EncryptOption} */ var eopt = { mode: Zga.Crypto.Mode.AES_128, pubkeys: [{ c: cert, p: ["copy", "modify", "copy-extract", "annot-forms", "fill-forms", "extract", "assemble"], }], }; var cyptor = new Zga.PdfCryptor(eopt); var pdfdoc = await cyptor.encryptPdf(pdf); u8arr = await pdfdoc.save({"useObjectStreams": false}); return new Blob([u8arr], {"type" : "application/pdf"}); } ``` ### Response Returns a Promise that resolves to a Blob containing the protected PDF. ``` -------------------------------- ### protect2 - Set public-key certificate protection to the PDF Source: https://github.com/zboris12/zgapdfsigner/blob/main/README.md Encrypts a PDF with public-key certificate protection using AES_128 encryption mode and specified permissions. ```APIDOC ## protect2(pdf, cert) ### Description Sets public-key certificate protection to the PDF using AES_128 encryption mode. ### Method Function call ### Parameters - **pdf** (ArrayBuffer) - Required - The PDF file to protect. - **cert** (ArrayBuffer) - Required - The certificate used for encryption. ### Request Example ```js async function protect2(pdf, cert){ /** @type {EncryptOption} */ var eopt = { mode: Zga.Crypto.Mode.AES_128, pubkeys: [{ c: cert, p: ["copy", "modify", "copy-extract", "annot-forms", "fill-forms", "extract", "assemble"], }], }; var cyptor = new Zga.PdfCryptor(eopt); var pdfdoc = await cyptor.encryptPdf(pdf); u8arr = await pdfdoc.save({"useObjectStreams": false}); return new Blob([u8arr], {"type" : "application/pdf"}); } ### Response Returns a Promise that resolves to a Blob containing the protected PDF. ``` -------------------------------- ### protect2 - Set public-key certificate protection to the PDF Source: https://github.com/zboris12/zgapdfsigner/blob/main/README.md Encrypts a PDF with public-key certificate protection using AES_128 encryption mode and specified permissions. ```APIDOC ## protect2(pdf, cert) ### Description Sets public-key certificate protection to the PDF using AES_128 encryption mode. ### Method Function call ### Parameters - **pdf** (ArrayBuffer) - Required - The PDF file content as an ArrayBuffer. - **cert** (ArrayBuffer) - Required - The certificate used for encryption. ### Request Example ```js async function protect2(pdf, cert){ /** @type {EncryptOption} */ var eopt = { mode: Zga.Crypto.Mode.AES_128, pubkeys: [{ c: cert, p: ["copy", "modify", "copy-extract", "annot-forms", "fill-forms", "extract", "assemble"], }], }; var cyptor = new Zga.PdfCryptor(eopt); var pdfdoc = await cyptor.encryptPdf(pdf); u8arr = await pdfdoc.save({"useObjectStreams": false}); return new Blob([u8arr], {"type" : "application/pdf"}); } ### Response Returns a Promise that resolves to a Blob containing the protected PDF. ``` -------------------------------- ### protect2 - Set public-key certificate protection to the PDF Source: https://github.com/zboris12/zgapdfsigner/blob/main/README.md Encrypts a PDF with public-key certificate protection using AES_128 encryption mode and specified permissions. ```APIDOC ## protect2(pdf, cert) ### Description Sets public-key certificate protection to the PDF using AES_128 encryption mode. ### Method Function call ### Parameters - **pdf** (ArrayBuffer) - Required - The PDF file as an ArrayBuffer. - **cert** (ArrayBuffer) - Required - The certificate used for encryption. ### Request Example ```js async function protect2(pdf, cert){ /** @type {EncryptOption} */ var eopt = { mode: Zga.Crypto.Mode.AES_128, pubkeys: [{ c: cert, p: ["copy", "modify", "copy-extract", "annot-forms", "fill-forms", "extract", "assemble"], }], }; var cyptor = new Zga.PdfCryptor(eopt); var pdfdoc = await cyptor.encryptPdf(pdf); u8arr = await pdfdoc.save({"useObjectStreams": false}); return new Blob([u8arr], {"type" : "application/pdf"}); } ### Response Returns a Promise that resolves to a Blob containing the protected PDF. ``` -------------------------------- ### protect1 - Set password protection to the PDF Source: https://github.com/zboris12/zgapdfsigner/blob/main/README.md Encrypts a PDF with password-based protection using RC4_40 encryption mode and specified permissions. ```APIDOC ## protect1(pdf, upwd, opwd) ### Description Sets password protection to the PDF using RC4_40 encryption mode. ### Method Function call ### Parameters - **pdf** (ArrayBuffer) - Required - The PDF file as an ArrayBuffer. - **upwd** (string) - Required - User password. - **opwd** (string) - Required - Owner password. ### Request Example ```js async function protect1(pdf, upwd, opwd){ /** @type {EncryptOption} */ var eopt = { mode: Zga.Crypto.Mode.RC4_40, permissions: ["modify", "annot-forms", "fill-forms", "extract", "assemble"], userpwd: upwd, ownerpwd: opwd, }; var cyptor = new Zga.PdfCryptor(eopt); var pdfdoc = await cyptor.encryptPdf(pdf); u8arr = await pdfdoc.save({"useObjectStreams": false}); return new Blob([u8arr], {"type" : "application/pdf"}); } ### Response Returns a Promise that resolves to a Blob containing the protected PDF. ``` -------------------------------- ### Zga.PdfSigner.sign() - Invisible Signature Source: https://github.com/zboris12/zgapdfsigner/blob/main/README.md Signs a PDF with an invisible signature using a certificate and password. Returns a Promise that resolves to a Uint8Array of the signed PDF. ```APIDOC ## Zga.PdfSigner.sign(pdf, cert, pwd) ### Description Signs a PDF with an invisible signature using a certificate and password. ### Method sign ### Parameters - **pdf** (ArrayBuffer) - Required - The PDF file data as an ArrayBuffer. - **cert** (ArrayBuffer) - Required - The certificate (PFX/P12) data as an ArrayBuffer. - **pwd** (string) - Required - The password for the certificate. ### Request Example ```js var sopt = { p12cert: cert, pwd: pwd, permission: 1 }; var signer = new Zga.PdfSigner(sopt); var u8arr = await signer.sign(pdf); ``` ### Response Returns a Promise that resolves to a Uint8Array containing the signed PDF data. ``` ```APIDOC ## Zga.PdfSigner.sign(pdf) ### Description Signs a PDF document using the provided certificate and options. The signature can be invisible or visible with an image or text. ### Method sign(pdf) - asynchronous method returning a Promise ### Parameters - **pdf** (ArrayBuffer) - Required - The PDF file data as an ArrayBuffer. ### Request Example ```js var signer = new Zga.PdfSigner(sopt); var u8arr = await signer.sign(pdf); ``` ### Response Returns a Promise that resolves to a Uint8Array containing the signed PDF data. ``` -------------------------------- ### PdfFonts.from(pdfdoc) Source: https://github.com/zboris12/zgapdfsigner/wiki/API Loads embedded fonts from a PDF document. ```APIDOC ## PdfFonts.from(pdfdoc) ### Description Load embedded fonts from pdf document. ### Method from (static) ### Parameters - **pdfdoc** (PDFLib.PDFDocument) - Required - The target pdf document. ### Returns - **Promise** - A promise that resolves to a PdfFonts instance. ``` -------------------------------- ### CertsChain.isSelfSignedCert() Source: https://github.com/zboris12/zgapdfsigner/wiki/API Returns true if the certificate for signing is a self-signed certificate. ```APIDOC ## CertsChain.isSelfSignedCert() ### Description Returns true if the certificate for signing is a self-signed certificate. ### Method Function ### Signature isSelfSignedCert() :arrow_right: boolean ### Returns - **boolean** - True if the signing certificate is self-signed. ``` -------------------------------- ### u8arrToRaw Source: https://github.com/zboris12/zgapdfsigner/wiki/API Converts a Uint8Array to a raw string. This is a utility function for handling binary data. ```APIDOC ## u8arrToRaw ### Description Converts a Uint8Array to a raw string. ### Method Function ### Signature u8arrToRaw(uarr) :arrow_right: string ### Parameters - **uarr** (Uint8Array) - Required - The target Uint8Array ### Returns - **string** - The raw string representation of the input Uint8Array. ``` -------------------------------- ### queryTsa(data) Source: https://github.com/zboris12/zgapdfsigner/wiki/API Queries the TSA to sign the provided data and returns an error message if an error occurs. ```APIDOC ## queryTsa(data) ### Description Query TSA to sign the data and returns error message if error occurred. ### Method queryTsa ### Parameters - **data** (string) - Required - The data needs to be signed. ### Returns - **Promise** - A promise that resolves to an error message if an error occurred. ``` -------------------------------- ### rawToU8arr Source: https://github.com/zboris12/zgapdfsigner/wiki/API Converts a raw string to a Uint8Array. This is a utility function for handling binary data. ```APIDOC ## rawToU8arr ### Description Converts a raw string to a Uint8Array. ### Method Function ### Signature rawToU8arr(raw) :arrow_right: Uint8Array ### Parameters - **raw** (string) - Required - The target string ### Returns - **Uint8Array** - The Uint8Array representation of the input string. ``` -------------------------------- ### encryptObject(num, val) Source: https://github.com/zboris12/zgapdfsigner/wiki/API Encrypts the content of a specified PDF object. ```APIDOC ## Method: encryptObject(num, val) ### Description Encrypts the content of the specified PDF object. ### Parameters - **num** (number) - Required - The object number. - **val** (PDFLib.PDFObject) - Required - The target object. ```