Skip to content

Commit 60bfa61

Browse files
committed
update readme and version
1 parent d60299b commit 60bfa61

File tree

3 files changed

+27
-7
lines changed

3 files changed

+27
-7
lines changed

README.md

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,22 @@
11
# html2pdf
22
An HTML to PDF converter provided by RESTful API and command-line tool. Powered by `puppeteer`.
33

4-
## Usage
4+
## RESTful API
5+
The best reason to use this method is that we can use it on any programming languages and software that support HTTP requests.
56

6-
### RESTful API
7+
### Start server with npm
8+
```bash
9+
git clone https://github.com/iamdual/html2pdf
10+
npm install --production
11+
npm start
12+
```
13+
14+
### Start server with Docker
15+
```bash
16+
docker run -p 3000:3000 iamdual/html2pdf
17+
```
18+
19+
### Example usage (JSON POST)
720
```bash
821
curl -X POST 'http://localhost:3000/generate' \
922
--header 'Content-Type: application/json' \
@@ -14,11 +27,18 @@ curl -X POST 'http://localhost:3000/generate' \
1427
}' > google.pdf
1528
```
1629

17-
### Command-line
30+
### Example usage (Query parameters)
31+
```bash
32+
curl 'http://localhost:3000/generate?source=https://google.com&timeout=10' > google.pdf
33+
```
34+
35+
## Command-line tool
36+
It also support for command-line interface, so you can convert easily to a PDF.
1837
```bash
1938
npm install -g https://github.com/iamdual/html2pdf
2039
html2pdf '<!DOCTYPE html><strong>Hello world!</strong>' -o output.pdf
2140
html2pdf "https://www.google.com" --format A4 --timeout 10 -o google.pdf
41+
html2pdf ./example.html --format A4 --pageRanges 1 -o example.pdf
2242
```
2343

2444
## Parameters
@@ -32,7 +52,7 @@ html2pdf "https://www.google.com" --format A4 --timeout 10 -o google.pdf
3252
| format | string | Set paper format. Must be one of `A0`, `A1`, `A2`, `A3`, `A4`, `A5`, `A6`, `Letter`, `Legal`, `Tabloid`, `Ledger`. Default is `A4`. |
3353
| width | integer | Set PDF document width. Both height and width must be used together. It will disable `format` option. |
3454
| height | integer | Set PDF document height. Both height and width must be used together. It will disable `format` option. |
35-
| scale | float | Set scale. The value must be greater than or equals to `0.1`, or lower then or equals to `2`. Default is `1`. |
55+
| scale | float | Set scale. The value must be greater than or equals to `0.1`, or lower than or equals to `2`. Default is `1`. |
3656
| landscape | boolean | Enable landscape mode. To enable, the value should be true. Disabled by default. |
3757
| margin | string | Set margin(s) for the PDF document. It can be all four margin or specified by the values separated with space. Default is `0`. |
3858

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@iamdual/html2pdf",
3-
"version": "0.1.0",
3+
"version": "0.2.0",
44
"description": "HTML to PDF converter",
55
"main": "./src/index.js",
66
"scripts": {

0 commit comments

Comments
 (0)