Skip to content

Mini-Microservices/letspdf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

Releases

No releases published

Packages

No packages published