node-htmlpdf
Version:
Converts Html to Pdf file
66 lines (40 loc) • 1.19 kB
Markdown
#node-htmlpdf
Converts Html file or buffer to Pdf using headless Browser
#Installation
```bash
npm i node-htmlpdf
```
#Example
```js
const htmlpdf =require('node-htmlpdf')
let html =`
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<h1>Hello world</h1>
<p>Lorem ipsum dolor sit, amet consectetur adipisicing elit. Culpa odit veritatis dolor enim quia deleniti aut minus magni beatae. Sit atque rem vitae alias recusandae fugit sed aliquam nihil illo.</p>
</body>
</html>`
node-htmlpdf.create(
html,
{path:'./test.pdf',
format:'A4'},
null).then((buff)=>{
console.log(buff)
});
```
#Options
Path : "Path to create Pdf file"
format: A4, letter
landscape: Bool (true , false),
height: Height of Pdf
width: width of Pdf
margin: top, left , botton right
#### License
[MIT](https://choosealicense.com/licenses/mit/) Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.