Open Source JavaScript Library for PDF Files

Add Annotations, Image & Text to PDFs via Open Source Free JavaScript Library.

What is PDFjs?

PDFjs is an open source Portable Document Format (PDF) generation library that can best suites the server- and client-side applications development. PDF is popular across the world and several companies are using it to create & share documents or reports across the globe. With the help of PDFjs library, you just require a couple of commands to access and reuse PDF documents inside your own applications.

The library has incorporated support for several noticeable features, such as PDF documents creation, drawing shapes to PDFs, header and footer support, adding tables to PDF, AFM fonts & OTF font embedding, images insertion to PDF pages, PDF merging, adding pages to PDF, inserting & displaying text, exporting PDF to other file formats and many more.

Previous Next

Getting Started with PDFjs

The recommend and easiest way to install the PDFjs library is using npm, please use the following command to achieve it.

Install JsPDF using npm

 npm install pdfjs 

PDF Documents Creation via Free JavaScript API

PDF documents are always useful for companies and individuals to save and share information with each other. PDFjs library makes it easy for you to generate and modify PDF documents inside your application with just a couple of simple commands. The library also facilitates developers to add new pages, insert images, define document orientation, and much more.

Create PDF Annotations via Free JavaScript API

The open source PDFjs library supports creating PDF documents with Annotations. Annotations let developers add custom content inside PDF documents. There are various kinds of annotations that can be used in PDF documents, such as text, lines, notes or shapes, etc. PDFjs library fully supports and makes it easy for developers to create various types of PDF annotations inside their own applications. The following simple lines of code can add text annotations in PDF document in JavaScript.

  1. Include PDFjs Library
  2. Add Text Annotations
  3. Export PDF document

Add Text Annotations in PDF - JavaScript

const pdf = require('.lib')
// Add Text Annotations
module.exports = function(doc, { lorem, font }) {
  doc.text('goto B', { goTo: 'B' })
  doc.text('goto A', { goTo: 'A' })


Merging PDF Documents

The PDFjs library allows software developers to programmatically combine numerous PDF documents to one document inside their apps. The library enables programmers to generate a new PDF document from the existing one, add one specific page of an external PDF, implement kerning, adding whole pages of other PDFs and more. The library also gives users the ability to create custom PDF reports.

Adding Graphics to PDF Documents

Graphics and images are always useful for sharing better information and add more value to the piece of content. The PDFjs library facilitates JavaScript professional to insert graphics of their choice inside their JavaScript applications. You can use images types of images like JPEG or PNG inside a PDF file. You can also draw an ellipse, triangle, circle etc.