This website demonstrates the usage of the HTML to PDF Converter HTTP API. An instance of that API application is deployed via docker on https://html2pdf.fly.dev/api. It exposes a simple HTTP API to convert any HTML source code to a PDF file. That API is free for use, no authentication required. Full API docs.
A minimalistic example client using JavaScript in the browser:
async function generatePDF(html){
let pdfGeneratorUrl = 'https://html2pdf.fly.dev/api/generate'
const data = await fetch(pdfGeneratorUrl, {
method: 'POST',
headers: {
'content-type': "application/json",
accept: 'application/json'
},
body: JSON.stringify({ html })
})
if(data.ok){
return new Blob([await data.blob()], {type: 'application/pdf'})
}else{
throw await data.json()
}
}