chore: modularize PDF processing by extracting helper functions

This commit is contained in:
Catalin Pit
2025-11-06 10:20:04 +02:00
parent 3e84aa632f
commit 498a2be1c7
3 changed files with 202 additions and 189 deletions

View File

@ -1,6 +1,6 @@
import { PDFDocument } from '@cantoo/pdf-lib';
import { replacePlaceholdersInPDF } from './auto-place-fields';
import { removePlaceholdersFromPDF } from './auto-place-fields';
import { flattenAnnotations } from './flatten-annotations';
import { flattenForm, removeOptionalContentGroups } from './flatten-form';
@ -14,7 +14,7 @@ export const normalizePdf = async (pdf: Buffer) => {
removeOptionalContentGroups(pdfDoc);
await flattenForm(pdfDoc);
flattenAnnotations(pdfDoc);
const pdfWithoutPlaceholders = await replacePlaceholdersInPDF(pdf);
const pdfWithoutPlaceholders = await removePlaceholdersFromPDF(pdf);
return pdfWithoutPlaceholders;
};