Skip to content

Commit 33f30b8

Browse files
committed
update readme and packages.json
1 parent df49507 commit 33f30b8

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

README.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,27 @@
11
# html2pdf
2+
23
An HTML to PDF converter provided by RESTful API and command-line tool. Powered by `puppeteer`.
34

45
## RESTful API
6+
57
The best reason to use this method is that we can use it on any programming languages and software that support HTTP requests.
68

79
### Start server with Docker (recommended)
10+
811
```bash
912
docker run -p 3000:3000 iamdual/html2pdf
1013
```
1114

1215
### Start server with source
16+
1317
```bash
1418
git clone https://github.com/iamdual/html2pdf && cd html2pdf
1519
npm install
1620
npm start
1721
```
1822

19-
### Example usage (JSON POST)
23+
### API request with POST JSON
24+
2025
```bash
2126
curl -X POST 'http://localhost:3000/generate' \
2227
--header 'Content-Type: application/json' \
@@ -27,13 +32,16 @@ curl -X POST 'http://localhost:3000/generate' \
2732
}' > google.pdf
2833
```
2934

30-
### Example usage (Query parameters)
35+
### API request with query parameters
36+
3137
```bash
3238
curl 'http://localhost:3000/generate?source=https://google.com&timeout=10' > google.pdf
3339
```
3440

3541
## Command-line tool
42+
3643
It also support for command-line interface, so you can convert easily to a PDF.
44+
3745
```bash
3846
npm install -g https://github.com/iamdual/html2pdf
3947
html2pdf '<!DOCTYPE html><strong>Hello world!</strong>' -o output.pdf
@@ -42,8 +50,9 @@ html2pdf ./example.html --format A4 --pageRanges 1 -o example.pdf
4250
```
4351

4452
## Parameters
53+
4554
| Name | Type | Description |
46-
|------------|---------|-------------------------------------------------------------------------------------------------------------------------------------|
55+
| ---------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------- |
4756
| source | string | Set PDF document source. It must be specified. The source can be a URL or an HTML code. |
4857
| timeout | integer | Set connection timeout. Default is `10`. |
4958
| javascript | boolean | Enable JavaScripts. To enable, the value should be true. Disabled by default. |
@@ -57,4 +66,5 @@ html2pdf ./example.html --format A4 --pageRanges 1 -o example.pdf
5766
| 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`. |
5867

5968
## Author
69+
6070
Ekin Karadeniz (iamdual@icloud.com)

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"main": "./src/index.js",
66
"scripts": {
77
"test": "npx tsc && mocha ./dist/test",
8-
"start": "npx tsc && node ./dist/src/rest-api"
8+
"start": "npx tsc && node ./dist/src/rest-api",
9+
"clean": "rm -rf ./dist"
910
},
1011
"bin": {
1112
"html2pdf": "./bin/index.js"
@@ -32,7 +33,7 @@
3233
"@types/jest": "^29.5.0"
3334
},
3435
"devDependencies": {
35-
"@types/mocha": "^10.0.1",
36-
"mocha": "^10.2.0"
36+
"mocha": "^10.2.0",
37+
"@types/mocha": "^10.0.1"
3738
}
3839
}

0 commit comments

Comments
 (0)