"setup/git@code.vereign.com:docker/osticket.git" did not exist on "dec4f3ca88ec14bd583cdb7d0dbd85e5a23163e8"
Newer
Older
import { PdfData } from "pdfdataextract";
import { config } from "./config";
import { IGetMetaResponse } from "./types";
import { verifyPDF } from "./lib";
import { formatPdfTime } from "./lib/timeUtils";
import { AppError, GeneralError } from "./lib/errors";
import { isPDF } from "./lib/generalUtils";
// import { TimestampAndEnableLTV } from "./utils";
// import { PDFNet } from "@pdftron/pdfnet-node";
declare global {
interface Window {
PDFNet: any;
CoreControls: any;
}
}
initialize = async (licenseKey: string): Promise<void> => {
getPDFMeta = async (): Promise<IGetMetaResponse> => {
if (!(this.document instanceof Buffer)) {
throw new AppError("Document is not Buffer");
}
if (!isPDF(this.document)) {
throw new AppError("Only pdf file type is supported");
}
try {
const signaturesMeta = await verifyPDF(this.document);
const pdfMeta = await PdfData.extract(this.document, config);
title: pdfMeta.info.Title || "Unknown",
author: pdfMeta.info.Author || "Unknown",
creation_date: formatPdfTime(pdfMeta.info.CreationDate),
mod_date: formatPdfTime(pdfMeta.info.ModDate),
result["expired"] = signaturesMeta.expired;
// insertQrCode = async (
// imgBytes: ArrayBuffer,
// url: string,
// coords: SealCoords,
// scaleFactor: number,
// licenseKey: string,
// certPath: string,
// certTSAUrl: string
// ): Promise<ArrayBuffer> => {
// let buf;
// try {
// buf = await TimestampAndEnableLTV(
// this.document,
// certPath,
// certTSAUrl,
// imgBytes,
// coords
// );
// } catch (error) {
// console.log(error);
// throw new GeneralError("Could Not sign pdf");
// }