Use case
Use para renderizar relatórios, recibos, extratos ou telas internas no servidor. A ferramenta web serve para revisão manual; a API serve para automação repetível no servidor.
PDF Tools API
Coloque converter HTML para PDF no backend, em lotes ou no seu produto sem manter infraestrutura própria de PDF.
Credits
1 Credit / call
1 Credit per successful API request. Failed processing attempts are refunded automatically.
Pricing
1,000 Credits = $1
Every signed-in user receives 100 free API Credits each month.
Endpoint
/api/external/html-to-pdf/pdfUse your API Key in the x-api-key header.
Use para renderizar relatórios, recibos, extratos ou telas internas no servidor. A ferramenta web serve para revisão manual; a API serve para automação repetível no servidor.
curl -X POST https://itextmaster.com/api/external/html-to-pdf/pdf \
-H 'x-api-key: YOUR_API_KEY' \
-F 'html=@index.html;type=text/html' \
-F 'pageSize=A4' \
-F 'printBackground=true' \
--output html-to-pdf.pdfcurl -X POST https://itextmaster.com/api/external/html-to-pdf/pdf \
-H 'x-api-key: YOUR_API_KEY' \
-F 'html=@index.html;type=text/html' \
-F 'pageSize=A4' \
-F 'printBackground=true' \
--output html-to-pdf.pdfcurl -X POST https://itextmaster.com/api/external/html-to-pdf/pdf \
-H 'Content-Type: application/json' \
-H 'x-api-key: YOUR_API_KEY' \
-d '{
"html": "<!doctype html><html><body><h1>Report</h1></body></html>",
"pageSize": "A4",
"printBackground": true
}' \
--output html-to-pdf.pdfimport { writeFile } from 'node:fs/promises';
const response = await fetch('https://itextmaster.com/api/external/html-to-pdf/pdf', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'x-api-key': process.env.ITEXTMASTER_API_KEY
},
body: JSON.stringify({
html: '<!doctype html><html><body><h1>Report</h1></body></html>',
pageSize: 'A4',
printBackground: true
})
});
if (!response.ok) {
throw new Error(await response.text());
}
await writeFile('html-to-pdf.pdf', Buffer.from(await response.arrayBuffer()));import os
import requests
response = requests.post(
'https://itextmaster.com/api/external/html-to-pdf/pdf',
headers={
'Content-Type': 'application/json',
'x-api-key': os.environ['ITEXTMASTER_API_KEY'],
},
json={
'html': '<!doctype html><html><body><h1>Report</h1></body></html>',
'pageSize': 'A4',
'printBackground': True,
},
)
response.raise_for_status()
with open('html-to-pdf.pdf', 'wb') as f:
f.write(response.content)invalid_payloadO JSON ou multipart não contém HTML, URL ou arquivo obrigatório.
invalid_api_keyO x-api-key está ausente, inválido ou foi rotacionado.
insufficient_creditsA conta não tem API Credits suficientes.
conversion_failedA renderização no servidor não concluiu a conversão. Credits são devolvidos automaticamente quando falha.
html-to-pdf.pdf com cabeçalhos de Credits consumidos e saldo restante.
Content-TypeContent-DispositionX-Credits-ChargedX-Credit-BalanceSolicitações bem-sucedidas usam API Credits; falhas de processamento são devolvidas automaticamente. Usuários logados recebem 100 free API Credits por mês, e 1,000 Credits = $1.
Não. Ferramentas que rodam no navegador não consomem API Credits. Só chamadas com API Key entram na cobrança.
Não é recomendado. Guarde a API Key no backend, fila ou automação do servidor.
Create an API Key, test HTML para PDF API, and buy more Credits only when automation volume grows.