Renamed editMetadata to match V1 naming. Added Operations controller

This commit is contained in:
Saud Fatayerji
2023-11-11 18:35:33 +03:00
parent 2cb2116940
commit fd6b0740fd
8 changed files with 341 additions and 29 deletions

View File

@@ -3,14 +3,14 @@ import { PDFDocument, ParseSpeeds } from 'pdf-lib';
export type Metadata = {
Title: string | null | undefined; // The title of the document.
Author: string | null | undefined; // The author of the document.
Subject: string | null | undefined; // The subject of the document.
Keywords: string[] | null | undefined; // An array of keywords associated with the document.
Producer: string | null | undefined; // The producer of the document.
Creator: string | null | undefined; // The creator of the document.
CreationDate: Date | null | undefined; // The date when the document was created.
ModificationDate: Date | null | undefined; // The date when the document was last modified.
Title?: string; // The title of the document.
Author?: string; // The author of the document.
Subject?: string; // The subject of the document.
Keywords?: string[]; // An array of keywords associated with the document.
Producer?: string; // The producer of the document.
Creator?: string; // The creator of the document.
CreationDate?: Date; // The date when the document was created.
ModificationDate?: Date; // The date when the document was last modified.
}
/**
*
@@ -18,7 +18,7 @@ export type Metadata = {
* @param {Metadata} metadata - Set property to null or "" to clear, undefined properties will be skipped.
* @returns Promise<Uint8Array>
*/
export async function editMetadata(snapshot: string | Uint8Array | ArrayBuffer, metadata: Metadata): Promise<Uint8Array> {
export async function updateMetadata(snapshot: string | Uint8Array | ArrayBuffer, metadata: Metadata): Promise<Uint8Array> {
// Load the original PDF file
const pdfDoc = await PDFDocument.load(snapshot, {
parseSpeed: ParseSpeeds.Fastest,