---
title: "Generate pdf file from html/url using Weasyprint. Requires paid subscription. This is our premium pdf generator. It is the most accurate and feature rich pdf generator we have with support for pdf/a-1b, pdf/a-2b, pdf/a-3b, pdf/a-4b and pdf/ua-1."
method: POST
path: "/api/pdf/weasyprint"
tags: ["Pdf"]
---

# Generate pdf file from html/url using Weasyprint. Requires paid subscription. This is our premium pdf generator. It is the most accurate and feature rich pdf generator we have with support for pdf/a-1b, pdf/a-2b, pdf/a-3b, pdf/a-4b and pdf/ua-1.

`POST /api/pdf/weasyprint`

## Headers

- `X-Api-Version` string

## Request body

- WeasyPrintToPdfRequestDto — WeasyPrintToPdfRequestDto is the data transfer object for generating a pdf using Weasyprint.
  - `url` string, nullable — The url to generate pdf from. Url has precedence over HtmlBase64String value if both are set.
  - `htmlBase64String` string, nullable — Base64 encoded string with html. If property Url is set, it will be used, not HtmlBase64String.
  - `resources` object, nullable — This is a set of key-value pairs of digital resources like images that is referenced in the HtmlBase64String document. It uses the filename including relative path as key and the data is provided as a Base64 encoded string.
  - `weasyPrintToPdfArguments` object, nullable — Command line arguments passed to Weasyprint. Invalid arguments will be ignored. Invalid arguments are "v", "verbose", "version", "d", "debug", "q", "quiet", "h", "help", "u", "f", "format".

## Response `200`

Returns the newly created pdf file. Either the file directly or serialized as Json if Accept-header is set to application/json

- PdfResponseDto — When setting the Accept-header in the request to "application/json" the content of the pdf file will be return as Base64 encoded string. Note that converting data to Base64 encoded strings increases the response size with approximately 33%, if you can accept the a binary format it's better to use Accept-header "application/pdf".
  - `errorMessage` string, nullable — If any error occurs the message will be displayed in here
  - `pdfFileBase64String` string, nullable — The Base64 encoded string that is the pdf file.

## Other responses

- `400` — If any error occurs executing request
- `415` — If content-type of request is not set to application/json
- `429` — If you reach the monthly request limit for your subscription plan

---

[API](https://skmtc.net/pdfbroker/apis/pdfbroker-io-api.md) · [All operations](https://skmtc.net/pdfbroker/apis/pdfbroker-io-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/pdfbroker/pdfbroker-io-api/versions/c10982b50857/schema)
