mirror of
https://github.com/documenso/documenso.git
synced 2025-11-13 00:03:33 +10:00
This PR is handles the changes required to support envelopes. The new envelope editor/signing page will be hidden during release. The core changes here is to migrate the documents and templates model to a centralized envelopes model. Even though Documents and Templates are removed, from the user perspective they will still exist as we remap envelopes to documents and templates.
27 lines
711 B
TypeScript
27 lines
711 B
TypeScript
import type { PDFDocument } from '@cantoo/pdf-lib';
|
|
import { PDFSignature, rectangle } from '@cantoo/pdf-lib';
|
|
|
|
export const normalizeSignatureAppearances = (document: PDFDocument) => {
|
|
const form = document.getForm();
|
|
|
|
for (const field of form.getFields()) {
|
|
if (field instanceof PDFSignature) {
|
|
field.acroField.getWidgets().forEach((widget) => {
|
|
widget.ensureAP();
|
|
|
|
try {
|
|
widget.getNormalAppearance();
|
|
} catch {
|
|
const { context } = widget.dict;
|
|
|
|
const xobj = context.formXObject([rectangle(0, 0, 0, 0)]);
|
|
|
|
const streamRef = context.register(xobj);
|
|
|
|
widget.setNormalAppearance(streamRef);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
};
|