I need to generate pdf from html file and I thought about the use of chrome headless browser for that. So, in my app.component.ts I added below method for that.
import RenderPDF from 'chrome-headless-render-pdf';
public downloadPdf(): void {
RenderPDF.generateSinglePdf('http://google.com', 'outputPdf.pdf');
}
But when I tried to compile the application, it gives this error,
ERROR in ./node_modules/chrome-headless-render-pdf/index.js Module not found: Error: Can't resolve 'fs' in 'D:\Local_copies\my-angular-app\n ode_modules\chrome-headless-render-pdf'
I tried to fix it by adding "browser": { "fs": false } but it didn't work.
I'm new for Angular and have not much experience. So, if someone know how to use chrome headless browser to generate PDF in Angular, please help me..
Not sure if you've resolved this yet but looking at the error code it appears chrome-headless-render-pdf has not been imported from npm of it has not been added in the main app.modules file. Try opening a terminal and running the following code.
npm i chrome-headless-render-pdf