chore: enhance envelope creation with placeholder extraction and removal

This commit is contained in:
Catalin Pit
2025-11-10 10:08:59 +02:00
parent 358ba2dd6f
commit c615e30633
4 changed files with 42 additions and 18 deletions

View File

@ -1,6 +1,5 @@
import { PDFDocument } from '@cantoo/pdf-lib';
import { removePlaceholdersFromPDF } from './auto-place-fields';
import { AppError } from '../../errors/app-error';
import { flattenAnnotations } from './flatten-annotations';
import { flattenForm, removeOptionalContentGroups } from './flatten-form';
@ -23,7 +22,8 @@ export const normalizePdf = async (pdf: Buffer) => {
removeOptionalContentGroups(pdfDoc);
await flattenForm(pdfDoc);
flattenAnnotations(pdfDoc);
const pdfWithoutPlaceholders = await removePlaceholdersFromPDF(pdf);
return pdfWithoutPlaceholders;
const normalizedPdfBytes = await pdfDoc.save();
return Buffer.from(normalizedPdfBytes);
};