Skip to content

Latest commit

 

History

History
38 lines (27 loc) · 1.3 KB

README.md

File metadata and controls

38 lines (27 loc) · 1.3 KB

PDF Generator Microservices

A service to generate very basic pdfs using the pdfmake library. Generating pdfs on the client can be expensive, so pawn off the process to a server.

Usage

const headers = new Headers();
headers.append("Content-Type", "application/json");

const docDefinition = {...}
const options = {...}

const json = JSON.stringify({
  document: docDefinition,
  options,
});

const res = await fetch("https://letspdf.vercel.app/api/make", {
  method: 'POST',
  headers: headers,
  body: json
})
const json = await res.json()

JSON structure

If you're using Typescript you're able to install the type definitions to ensure the data you pass is correct.

yarn add @types/pdfmake

If the response was successful, the message property will contain a base 64 string, from there you need to use a package like b64-to-blob to convert the string to a blob.