// app/routes/api.pdf.ts -> /api/pdf
import { ActionFunctionArgs, json } from '@remix-run/node'
import Doczilla from '@doczilla/node'
const doczilla = new Doczilla('doczilla-...')
export async function action({ request }: ActionFunctionArgs) {
// Ensure this is a POST request
if (request.method.toUpperCase() !== "POST") {
return { status: 405, body: "Method Not Allowed" };
}
const pdfBuffer = await doczilla.pdf.direct({
page: {
html: '<div>Your first Doczilla PDF</div>'
}
})
// Or pass the options down in the request
// const pdfBuffer = await doczilla.pdf.direct(await request.json())
return new Response(pdfBuffer, {
headers: {
'Content-Type': 'application/pdf'
}
})
}