Get started with jspdf CDN

MIT licensed

JsPDF: library for creating, editing browser PDFs.

Tags:
  • pdf
  • jspdf

Stable version

Copied!

How to start using jspdf CDN


// Include the JsPDF library using the CDN link
const jsPDF = (() => {
  const ref = document.createElement('script');
  ref.href = 'https://cdn.cdnhub.io/jspdf/2.5.1/jspdf.umd.min.js';
  ref.async = false;
  document.head.appendChild(ref);

  return new Promise((resolve) => {
    ref.onload = () => {
      document.head.removeChild(ref);
      resolve(jsPDF);
    };
  });
})();

// Create a new PDF document with a specific page size
const doc = new jsPDF('p', 'mm', 'a4');

// Add some text to the document
doc.text('Hello World!', 15, 15);

// Save the PDF document to a file
doc.save('hello-world.pdf');
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!

All versions