marcbachmann / node-html-pdf

This repo isn't maintained anymore as phantomjs got dreprecated a long time ago. Please migrate to headless chrome/puppeteer.
MIT License
3.56k stars 543 forks source link

[Angular 2] How to use this packages in Angular2 With Typescript #414

Open NJJ2 opened 6 years ago

NJJ2 commented 6 years ago

Hi,

Basically, I need to save html page into pdf. Currently, I'm using this package in server side with nodejs. but creating in server side and downloading that in client side is too time consuming ( around 1min). now I planing to do it completly client side with Angular 2 with typescript. but when I compile project with ng serve I'm getting forllowing error

ERROR in ./node_modules/html-pdf/lib/pdf.js
Module not found: Error: Can't resolve 'child_process' in '/home/naveen/Project/node_modules/html-pdf/lib'
ERROR in ./node_modules/phantomjs-prebuilt/lib/phantomjs.js
Module not found: Error: Can't resolve 'child_process' in '/home/naveen/Project/ICARUS-REVIEW/node_modules/phantomjs-prebuilt/lib'

Someone please give some suggetstion to get it work in angular 2 projects.

sean256 commented 6 years ago

AFAIK that is not possible. This uses PhantomJS which is a native headless WebKit binary.

vjijardar commented 6 years ago

getting same issue

ERROR in ./~/html-pdf/lib/pdf.js Module not found: Error: Can't resolve 'child_process' in 'C:\Users\admin\Desktop**\node_modules\html-pdf\lib' @ ./~/html-pdf/lib/pdf.js 2:19-43 @ ./~/html-pdf/lib/index.js @ ./src/app/.ts @ ./src/app/app.module.ts @ ./src/main.ts @ multi webpack-dev-server/client?http://localhost:4200 ./src/main.ts

ERROR in ./~/phantomjs-prebuilt/lib/phantomjs.js Module not found: Error: Can't resolve 'child_process' in 'C:\Users\admin\Desktop****\node_modules\phantomjs-prebuilt\lib' @ ./~/phantomjs-prebuilt/lib/phantomjs.js 10:12-36 @ ./~/html-pdf/lib/pdf.js @ ./~/html-pdf/lib/index.js @ ./src/app/.ts @ ./src/app/app.module.ts @ ./src/main.ts @ multi webpack-dev-server/client?http://localhost:4200 ./src/main.ts