https://github.com/131/htmltar-to-pdf
Convert HTML tar archives to PDFs
https://github.com/131/htmltar-to-pdf
Last synced: about 1 year ago
JSON representation
Convert HTML tar archives to PDFs
- Host: GitHub
- URL: https://github.com/131/htmltar-to-pdf
- Owner: 131
- License: mit
- Created: 2019-08-09T22:30:37.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2023-06-07T22:01:21.000Z (about 3 years ago)
- Last Synced: 2024-10-29T02:10:20.674Z (over 1 year ago)
- Language: JavaScript
- Size: 367 KB
- Stars: 3
- Watchers: 4
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://github.com/131/htmltar-to-pdf/actions/workflows/test.yml)
[](https://coveralls.io/github/131/htmltar-to-pdf?branch=master)
[](https://www.npmjs.com/package/htmltar-to-pdf)
[](http://opensource.org/licenses/MIT)
[](https://www.npmjs.com/package/eslint-plugin-ivs)
# Motivation
[htmltar-to-pdf](https://github.com/131/htmltar-to-pdf) is a wrapper around phantomjs that convert a HTML payload (in a tarball) as a PDF (or png) file.
Using a simple tar as input makes the whole API simple & stable.
# API/usage
```
const html2pdf = require('htmltar-to-pdf');
const infile = '/some/path/to/a/file.tar';
let output_path = await html2pdf(infile, [format = "pdf|png", [options ]]); //will capture (index.html in tar file)
//you wont make it any simplier...
console.log("Please find a fine PDF in", output_path);
```
## Configuration parameters & defaults values
```
let opts = {
format : 'A4',
orientation : 'portrait || landscape',
dpi : 72,
index : 'index.html',
waitForDom : true,
waitForEvent : 'customPageEvent',
waitForTimeout : 5000 // timeout as ms
//configure one will set up #page-footer #page-header
pageBodyAnchor : null,
footerFile : null,
headerFile : null,
};
```
# Credits
* [131 - auhor](https://github.com/131)
* [kalmani](https://github.com/kalmani)
* [ariya's phantomjs](https://github.com/ariya/phantomjs)