Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 12111

How to use fs module (file system) with Angular 17?

$
0
0

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:enter image description here

Is there any way i can use fs with Angular?Is there any alternative for fs ?


Viewing all articles
Browse latest Browse all 12111

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>