npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

survey-pdf

v3.0.3

Published

Renders JSON-driven SurveyJS forms and their responses as PDF documents in the browser or Node.js: fillable interactive PDF forms (AcroForm) or static printouts.

Readme

Build Status Software License Open Issues Closed Issues

SurveyJS PDF Generator: JavaScript Library for PDF Forms

SurveyJS PDF Generator is a JavaScript library that renders SurveyJS forms and collected responses as PDF documents. Generate editable PDF forms (AcroForm) for offline completion, export completed forms as read-only PDFs, or create printable copies of blank forms using the same JSON form definition you use on the web.

The survey-pdf package extends survey-core and is built on top of jsPDF. It supports React, Angular, Vue, and plain JavaScript applications. PDF files can be generated entirely in the browser or on a Node.js server without sending form definitions or response data to SurveyJS.

How It Works

SurveyJS PDF Generator uses the same JSON form definition as SurveyJS Form Library. You can generate a PDF from a blank form definition or populate it with collected response data before export.

Your application can:

  1. Create a SurveyJS JSON form definition with SurveyJS Survey Creator, AI, or manually.
  2. Render the form on the web with SurveyJS Form Library.
  3. Pass the same JSON definition to PDF Generator (this package).
  4. Optionally add collected response data.
  5. Generate an editable PDF form or a read-only PDF document.
  6. Download the PDF in the browser or generate it on a Node.js server.

Because the web form and PDF share the same SurveyJS definition, form structure, conditional visibility, expressions, localization, and value formatting can remain consistent across both outputs.

Installation

npm install survey-pdf

survey-pdf also runs in Node.js (for example, to generate PDFs on the server after a form is submitted). See the Create PDF Forms in Node.js guide.

Usage

Create a SurveyPDF instance from the same JSON you feed to the SurveyJS Form Library, optionally assign collected responses to data, and call save():

import { SurveyPDF } from "survey-pdf";

const surveyJson = {
    elements: [
        { name: "firstName", title: "Enter your first name:", type: "text" },
        { name: "satisfaction", title: "How satisfied are you?", type: "rating" }
    ]
};

const pdfDocOptions = {
    fontSize: 12
};

const surveyPdf = new SurveyPDF(surveyJson, pdfDocOptions);
surveyPdf.data = { firstName: "Jane", satisfaction: 5 };
surveyPdf.save("survey-response.pdf");

Because SurveyPDF extends SurveyModel from survey-core, all of the survey model's logic—visibility, expressions, localization, value formatting—works unchanged. See IDocOptions for available page-format, margin, font, and compression settings.

The generated document is an interactive fillable form (AcroForm) by default. To produce a static, non-interactive printout instead, set readOnly to true:

surveyPdf.readOnly = true;

See Customize PDF Form Settings for this and other rendering options.

Related Packages

| Package | Purpose | | --- | --- | | survey-core | Platform-independent survey model (peer dependency) | | survey-react-ui | React renderer for the web form | | survey-angular-ui | Angular renderer for the web form | | survey-vue3-ui | Vue 3 renderer for the web form | | survey-js-ui | HTML/CSS/JavaScript renderer for the web form |

Get Started

Key Features

PDF Generation and Export

  • Generate PDFs from SurveyJS JSON form definitions
  • Export blank or completed forms
  • Generate editable AcroForm PDFs or read-only documents
  • Generate PDFs in the browser or Node.js
  • Convert output to Blob, Base64, etc.

PDF Appearance and Layout

The appearance of generated PDF forms is customized through shared themes, layout presets, and styles config API.

Themes

Colors, shadows, and other theme-level appearance values can be inherited from the active SurveyJS theme through the same --sjs2-* design tokens used by survey-core, which helps keep web forms and generated PDFs visually aligned.

Pass an ITheme object to applyTheme() to reuse a web theme's colors, shadows, and elevation in the PDF. See PDF Appearance Customization and the PDF Generator v3 announcement.

Layout Presets

Control PDF-specific variables—spacing, sizing, typography, border radius. Import Compact (the default, optimized for dense forms and reduced page count) or Spacious (optimized for readability) from survey-pdf/layouts and pass it to applyLayout():

```js
import { Spacious } from "survey-pdf/layouts";

surveyPdf.applyLayout(Spacious);
```

Styles Config API

Adjust individual elements of the form—titles, question containers, input fields, labels, panels, matrices—including colors, font size, font style, line height, padding, borders, and spacing, without rendering hacks or event handlers.

PDF Form Filler

Collect responses online with SurveyJS Form Library and then use pdf-form-filler to populate existing PDF forms with response data. Unlike SurveyPDF, which generates a new PDF from a SurveyJS form definition, pdf-form-filler writes collected SurveyJS responses into fields in an existing PDF template. See the Fill a PDF Form with Web Form Responses guide to learn more.

Documentation

For AI coding agents: https://surveyjs.io/llms.txt indexes the documentation. Any documentation page is also available as raw Markdown — append .md to its URL, for example https://surveyjs.io/pdf-generator/documentation/get-started-html-css-javascript.md.

SurveyJS Product Family

| Product | Purpose | License | | --- | --- | --- | | Form Library | Render dynamic forms from JSON | MIT | | Survey Creator | Drag-and-drop form builder UI | Commercial | | Dashboard | Visualize and analyze collected results | Commercial | | PDF Generator | Generate editable and read-only PDFs from SurveyJS forms and responses (this package) | Commercial | | AI Form Response Extractor | Extract responses from paper forms, PDFs, and images into a SurveyJS schema (ai-form-response-extractor) | MIT |

Build from Source

Requires Node.js 20 or later.

  1. Clone the repo

    git clone https://github.com/surveyjs/survey-pdf.git
    cd survey-pdf
  2. Install dependencies

    npm install

    survey-pdf depends on survey-core. The dependencies entry in package.json points to ../survey-library/packages/survey-core/build, so if you build against a local survey-library checkout, build survey-core first (see survey-core build instructions). Otherwise, replace that entry with a published survey-core version before running npm install.

  3. Build the library

    npm run build:all

    Build output goes to the build directory. npm run build produces the main bundle; npm run build:all also builds the embeddable fonts bundle, the interactive-forms (pdf-form-filler) bundle, and the layout presets. Use npm run watch:dev while developing.

  4. Run the local examples

    npm run serve

    This serves the package directory at http://localhost:7777/. The examples load the bundles from build, so run npm run build:all (step 3) first — npm start only rebuilds the main bundle, which leaves the form-filler examples without build/pdf-form-filler.js.

    The examples folder contains runnable pages: examples/jspdf generates a PDF from a survey definition, while examples/forms/pdf-lib and examples/forms/pdfjs fill an existing PDF with survey responses through the pdf-lib and PDF.js adapters.

  5. Run unit tests

    Unit tests use Vitest in a jsdom environment. PDF output is verified by snapshotting the computed layout — see src/helper_test.ts.

    npm run test                    # whole suite
    npm run test:watch              # watch mode
    npm run test:update-snapshots   # regenerate snapshots
    npx vitest run tests/flat_checkbox.test.ts   # a single file
    npx vitest run -t "test name"                # tests matching a substring

Licensing

SurveyJS PDF Generator requires a commercial license for each software developer who works with the SurveyJS APIs or implements the integration.