How to use the jspdf/dist/jspdf.node.min function in jspdf

To help you get started, we’ve selected a few jspdf examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github obezuk / cf-worker-pdf-generation / src / index.js View on Github external
async function handleRequest(event) {

  var jsPDF = require('jspdf/dist/jspdf.node.min');

  var doc = new jsPDF({
    "orientation": "p",
    "unit": "mm",
    "format": "a4"
  });

  var xmargin = 25.4;
  var ymargin = 25.4;

  var imgResponse = await fetch('https://regmedia.co.uk/2017/06/26/cloudflarelogo.jpg', {
    "cf": {
      "cacheTtl": 9999999999999999999
    }
  });

  var imgData = _arrayBufferToBase64(await imgResponse.arrayBuffer());
  doc.addImage(imgData, 'JPEG', xmargin, ymargin);

jspdf

PDF Document creation from JavaScript

MIT
Latest version published 2 months ago

Package Health Score

97 / 100
Full package analysis