"include/git@code.vereign.com:docker/osticket.git" did not exist on "630226fd63ba1527808e6a7512be09f748a51fc5"
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";
class PDFparser {
readonly document;
constructor(document: Buffer) {
this.document = document;
}
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;
scaleFactor: number,
licenseKey: string,
certPath: string,
certTSAUrl: string
await PDFNet.initialize(licenseKey);
let buf;
try {
buf = await TimestampAndEnableLTV(
this.document,
certPath,
certTSAUrl,
imgBytes,
coords
);
} catch (error) {
console.log(error);
throw new GeneralError("Could Not sign pdf");
}