Category : pdfkit

I just want to return a pdf in response to a GET Request at my Strapi endpoint. Strapi uses Koa, and the Strapi controller atm look as follows: const PDFDocument = require("pdfkit"); module.exports = { async printOne(ctx) { const doc = new PDFDocument(); ctx.set("Content-Type", "application/pdf"); // HTTP response doc.pipe(ctx.res); // add stuff to PDF doc.text("Hello ..

Read more

const { Storage } = require("@google-cloud/storage"); const storage = new Storage({ keyFilename: "./xxx-path-to-key(locally).json", projectId: "my project ID", }); exports.get_data = functions.https.onRequest(async (req, res) => { const pdf = async () => { const doc = new PDFDocument(); doc.text("Hello, World!"); doc.end(); return await getStream.buffer(doc); }; const pdfBuffer = await pdf(); const pdfBase64string = pdfBuffer.toString("base64"); //getting string ..

Read more