diff --git a/dist/utils.d.ts b/dist/utils.d.ts index 5bb1449ceaaced93f3188b1c335550ed15032651..ce9bafbadd86f845dd2df12ee700814096bb454a 100644 --- a/dist/utils.d.ts +++ b/dist/utils.d.ts @@ -1 +1 @@ -export declare const TimestampAndEnableLTV: (in_docpath: any, tsa_url: any, in_trusted_cert_path: any, in_appearance_img_path: any, coords: any) => Promise<any>; +export declare const TimestampAndEnableLTV: (docBuffer: ArrayBuffer, certPath: string, certTSAUrl: string, imgBytes: ArrayBuffer, coords: any) => Promise<ArrayBuffer>; diff --git a/dist/utils.js b/dist/utils.js index 2d78ea6988869736d63187bbb9fa185f451b55a1..3fc0eaa14cd67f92bc2dcd60a28362108a3f80e4 100644 --- a/dist/utils.js +++ b/dist/utils.js @@ -11,13 +11,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge Object.defineProperty(exports, "__esModule", { value: true }); exports.TimestampAndEnableLTV = void 0; const pdfnet_node_1 = require("@pdftron/pdfnet-node"); -const TimestampAndEnableLTV = (in_docpath, tsa_url, in_trusted_cert_path, in_appearance_img_path, coords) => __awaiter(void 0, void 0, void 0, function* () { - const doc = yield pdfnet_node_1.PDFNet.PDFDoc.createFromBuffer(in_docpath); +const TimestampAndEnableLTV = (docBuffer, certPath, certTSAUrl, imgBytes, coords) => __awaiter(void 0, void 0, void 0, function* () { + const doc = yield pdfnet_node_1.PDFNet.PDFDoc.createFromBuffer(docBuffer); doc.initSecurityHandler(); - const tst_config = yield pdfnet_node_1.PDFNet.TimestampingConfiguration.createFromURL(tsa_url); + const tst_config = yield pdfnet_node_1.PDFNet.TimestampingConfiguration.createFromURL(certTSAUrl); const opts = yield pdfnet_node_1.PDFNet.VerificationOptions.create(pdfnet_node_1.PDFNet.VerificationOptions.SecurityLevel.e_compatibility_and_archiving); - yield opts.addTrustedCertificateUString(in_trusted_cert_path); - const img = yield pdfnet_node_1.PDFNet.Image.createFromMemory2(doc, in_appearance_img_path); + yield opts.addTrustedCertificateUString(certPath); + const img = yield pdfnet_node_1.PDFNet.Image.createFromMemory2(doc, imgBytes); //make this dynamic with canvas lib const imgWidth = 300; const imgHeight = 300; diff --git a/src/utils.ts b/src/utils.ts index b9459ff8e556762efb2217d91b9a1a3130a7ab72..829a241bb4e9b33680779f18b811fedd1cc915ce 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1,24 +1,24 @@ import { PDFNet } from "@pdftron/pdfnet-node"; export const TimestampAndEnableLTV = async ( - in_docpath, - tsa_url, - in_trusted_cert_path, - in_appearance_img_path, - coords -) => { - const doc = await PDFNet.PDFDoc.createFromBuffer(in_docpath); + docBuffer: ArrayBuffer, + certPath: string, + certTSAUrl: string, + imgBytes: ArrayBuffer, + coords: any +): Promise<ArrayBuffer> => { + const doc = await PDFNet.PDFDoc.createFromBuffer(docBuffer); doc.initSecurityHandler(); const tst_config = await PDFNet.TimestampingConfiguration.createFromURL( - tsa_url + certTSAUrl ); const opts = await PDFNet.VerificationOptions.create( PDFNet.VerificationOptions.SecurityLevel.e_compatibility_and_archiving ); - await opts.addTrustedCertificateUString(in_trusted_cert_path); + await opts.addTrustedCertificateUString(certPath); - const img = await PDFNet.Image.createFromMemory2(doc, in_appearance_img_path); + const img = await PDFNet.Image.createFromMemory2(doc, imgBytes); //make this dynamic with canvas lib const imgWidth = 300;