Use foliojs/PDFKit 0.10 to insert a signature placeholder.
npm install @signpdf/placeholder-pdfkit010for 

Works on top of PDFKit 0.10.0 and given a PDFDocument that is in the works, adds an e-signature placeholder. When the PDF is ready you can pass it to @signpdf/signpdf to complete the process.
You will need $ npm i -S @signpdf/signpdf @signpdf/placeholder-pdfkit010 node-forge and a look at the pdfkit010.js example.
* Make sure to have a look at the docs of the @signpdf family of packages.
* Feel free to copy and paste any part of this code. See its defined Purpose.
Signing in detached mode makes the signature length independent of the PDF's content length, but it may still vary between different signing certificates. So every time you sign using the same P12 you will get the same length of the output signature, no matter the length of the signed content. It is safe to find out the actual signature length your certificate produces and use it to properly configure the placeholder length.
To produce PAdES compliant signatures, the ETSI Signature Dictionary SubFilter value must be ETSI.CAdES.detached instead of the standard Adobe value.
This can be declared using the subFilter option argument passed to pdfkitAddPlaceholder and plainAddPlaceholder.
``js
import { pdfkitAddPlaceholder } from '@signpdf/placeholder-pdfkit010';
import { SUBFILTER_ETSI_CADES_DETACHED } from '@signpdf/utils';
const pdfToSign = pdfkitAddPlaceholder({
...,
subFilter: SUBFILTER_ETSI_CADES_DETACHED,
});
``