--- title: HTML --- Gotenberg provides the endpoint `/convert/html` for HTML conversions. It accepts `POST` requests with a `multipart/form-data` Content-Type. ## Basic The only requirement is to send a file named `index.html`: it is the file which will be converted to PDF. For instance: ```html
of
``` The following classes allow you to inject printing values: * `date`: formatted print date * `title`: document title * `pageNumber`: current page number * `totalPage`: total pages in the document > **Attention:** the CSS properties are independant of the ones used in the `index.html` file. > Also, `footer.html` CSS properties override the ones from `header.html`. ### Guzzle ```bash $ curl --request POST \ --url http://localhost:3000/convert/html \ --header 'Content-Type: multipart/form-data' \ --form files=@index.html --form files=@header.html --form files=@footer.html > result.pdf ``` ### Go ```golang import "github.com/thecodingmachine/gotenberg/pkg" func main() { c := &gotenberg.Client{Hostname: "http://localhost:3000"} req := &gotenberg.HTMLRequest{ IndexFilePath: "index.html", Options: &gotenberg.HTMLOptions{ HeaderFilePath: "header.html", FooterFilePath: "footer.html", }, } dest := "result.pdf" c.Store(req, dest) } ``` ### PHP TODO ## Assets You may also send additional files. For instance, images, fonts, stylesheets and so on. The only requirement is to make sure that their paths are on the same level as the `index.html` file. In others words, this will work: ```html
```
But this won't:
```html
```
You may also use *remote* paths for Google fonts, images and so on.
> If you want to install fonts directly in the Gotenberg Docker image,
> see to the [fonts section](#office.fonts).
### Guzzle
```bash
$ curl --request POST \
--url http://localhost:3000/convert/html \
--header 'Content-Type: multipart/form-data' \
--form files=@index.html
--form files=@style.css
--form files=@img.png
--form files=@font.woff
> result.pdf
```
### Go
```golang
import "github.com/thecodingmachine/gotenberg/pkg"
func main() {
c := &gotenberg.Client{Hostname: "http://localhost:3000"}
req := &gotenberg.HTMLRequest{
IndexFilePath: "index.html",
AssetFilePaths: []string{
"style.css",
"img.png",
"font.woff",
},
}
dest := "result.pdf"
c.Store(req, dest)
}
```
### PHP
TODO
## Paper size, margins, orientation
You may also customize the resulting PDF paper.
By default, it will be rendered in `A4` size with `1 inch` margins and `portrait` orientation.
> Paper size and margins have to be provided in `inches`.
> Also, you have to set both `paperWidth` and `paperHeight`. Same for margins.
### Guzzle
```bash
$ curl --request POST \
--url http://localhost:3000/convert/html \
--header 'Content-Type: multipart/form-data' \
--form files=@index.html
--form paperWidth=8.27
--form paperHeight=11.27
--form marginTop=0
--form marginBottom=0
--form marginLeft=0
--form marginRight=0
--form landscape=true
> result.pdf
```
### Go
```golang
import "github.com/thecodingmachine/gotenberg/pkg"
func main() {
c := &gotenberg.Client{Hostname: "http://localhost:3000"}
req := &gotenberg.HTMLRequest{
IndexFilePath: "index.html",
Options: &gotenberg.HTMLOptions{
PaperSize: gotenberg.A4,
PaperMargins: gotenberg.NoMargins,
Landscape: true
},
}
dest := "result.pdf"
c.Store(req, dest)
}
```
### PHP
TODO