Editable PDF Forms using NodeJS and PDF-LIB

Yogesh Rajput / Senior NodeJS Developer

PDFMake is a popular library for generating PDF documents in web applications, offering a high level of customization and flexibility in the creation of PDF content. When it comes to creating PDF forms or editable PDF files—where users can interact with the document by filling out forms or editing text—PDFMake does not natively support these features.

Do check check our previous post on building complex PDF files using PDF-Make and NodeJS.


Using PDF-Lib to generate PDF forms and fill PDFs with existing templates is an excellent choice for projects requiring interactive PDF functionality. PDF-Lib is a powerful library that allows you to create, modify, and interact with PDF files in JavaScript, making it suitable for both server-side and client-side applications.

With PDF-Lib, you can:

  • Generate PDF Forms: You can programmatically create new PDF documents and add form fields to them. This includes various types of form fields such as text fields, checkboxes, radio buttons, dropdown lists, and more. You can customize these form fields with specific properties such as position, size, default values, and font settings.

  • Fill Existing PDF Forms: PDF-Lib enables you to load existing PDF documents and programmatically fill in form fields. This is particularly useful for automating the process of filling out PDF forms with data from a database or user input. You can modify the values of existing form fields and then save the modified PDF.

  • Edit or Modify PDF Documents: Beyond working with form fields, PDF-Lib allows you to add or modify text, images, vector graphics, and more. You can also use it to merge multiple PDFs into one document, split a PDF into multiple documents, or add pages to a PDF.

  • Work with Templates: By loading existing PDFs as templates, you can use PDF-Lib to overlay additional content such as text, images, or even new form fields on top of the template. This allows you to leverage existing document layouts and designs while customizing the content for different needs.

If you need to work with PDF forms or editable PDFs in a web application or server environment, PDF-Lib is a robust solution that offers a wide range of features to meet these requirements.

Let's dive into how we are using it.

Use case

We recently had two use cases to play around with PDF files:

  • 1. Generate PDF forms and share to users to collect information
  • 2. Use existing PDF templates to fill up detail programmatically and share

Here is the sample PDF form that we had to generate and send out to our users so that they can fill up the details and send the updated PDF.

Sample PDF Form

It does require some effort to build the PDF forms precisely, but the library does support a lot of options to make simple to complex PDF forms.

PDF-Lib is useful to add validations and action buttons too. Please do note that some of those features will only work with Adobe Acrobat Reader.

Check documentation for more detail - https://pdf-lib.js.org/docs/api/classes/pdfbutton

Sample Repo

You can check the sample repo with examples on how to create template and how to use existing template.


There are many other libraries out there that does support multiple features, but for us PDFMake and PDF-Lib is going great job.

More articles

Invoke On-Prem Logic with AWS AppSync Pub/Sub

Cloud adoption and migration are skyrocketing, but that doesn't stop enterprises to continue using or building applications in their private data centers. Hybrid use cases are also growing in popularity to offload some tasks to Cloud services and also support on-prem applications with continuity. In this post we will look at one of the recent use cases we handled using AppSync Generic Pub/Sub.

Read more

AI as a Service vs. AI Models as a Services: Selecting The Right Tool for the Job

If phrases like "pre-trained AI models" and "AI-powered Services" leave you excited but a little confused, you're not alone. AI-as-a-Service has evolved beyond simple acronyms. Let's checkout two major branches of this landscape to clarify when each tool shine.

Read more

Tell us about your project

Our office

  • 408-409, SNS Platina
    Opp Shrenik Residecy
    Vesu, Surat, India
    Google Map