I'm using a pdf sign library that uses fs to read a pdf file.
unfortunately i can't use it because Angular applications typically run in the browser environment, and the fs module (file system) is a Node.js module for interacting with the file system, which isn't accessible directly in the browser.
I tried the following, i used http client to fetch the p12 certificate as arraybuffer then use subscribed data with Buffer:
PDFViewerApplication.pdfDocument.getData().then(async pdfData => { http.get('assets/AccuSign.p12', {responseType: 'arraybuffer'}).subscribe(async data => { const settings: SignerSettings = { rangePlaceHolder: 9999, signatureComputer: <P12SignatureComputerSettings>{ password: '1q2w3e', certificate: Buffer.from(data) }, signatureLength: 0 }; const parameters: SignVisualParameters = { pageNumber: 1, rectangle: { left: 50, top: 641, right: 264, bottom: 711 }, texts: [{ lines: ['Faris','Shomali' ] }, { lines: ['Digitally signed by','Faris Shomali','Date: 2023.11.03','20:28:46 +02\'00\'' ] } ] }; const pdfSigner = new PdfSigner(settings); const placeHolder = await pdfSigner.addPlaceholderAsync(Buffer.from(pdfData), parameters) });})
It didn't work and i got this error message:
Is there any way i can use fs with Angular?Is there any alternative for fs ?