PDF.js vs. Nutrient: The best PDF.js alternative for enterprise web apps

Table of contents

    Compare PDF.js and Nutrient Web SDK against the document tasks your users need to finish, from reading a PDF to saving reviewed or redacted output.
    PDF.js vs. Nutrient: The best PDF.js alternative for enterprise web apps
    Outgrowing PDF.js?

    See how Nutrient Web SDK compares on rendering fidelity, annotations, forms, and support.

    TL;DR

    PDF.js can serve document-viewing workflows, including production applications. Its full viewer provides more than the canvas rendering shown in a minimal example.

    Evaluate Nutrient Web SDK when the task calls for additional document operations, shared review, or commercial support. Compare the required components, deployment, and saved output using your own documents. Neither choice removes the application’s responsibility for access controls, persistence, and testing.

    When to evaluate Nutrient Web SDK as a PDF.js alternative

    Start with the step that users can’t complete. For example, a contract reviewer may need comments saved in the returned PDF, or a caseworker may need to remove sensitive details before sharing a file.

    Nutrient provides annotation tools, form handling, and redaction for these tasks. Shared annotation updates use Instant synchronization, which has additional deployment and licensing requirements.

    First check whether the current PDF.js viewer already supports the task. If it does, test its output before adding another product. If it doesn’t, compare the missing operation and its integration requirements using the SDK comparison and product documentation.

    Understanding the need for web-based PDF viewing

    Web applications handle PDFs for reports, invoices, legal documents, and collaborative content. The complexity varies by use case:

    • Basic viewing — Rendering static PDFs in a browser
    • Interactive documents — Forms, annotations, and digital signatures
    • Collaboration — Real-time editing and sharing
    • Security — Encrypted access to sensitive documents
    • Automation — Data extraction, redaction, and report generation

    PDF.js: An open source PDF viewer

    PDF.js parses and renders PDF documents in the browser. Its display API and full viewer(opens in a new tab) serve different purposes. The full viewer adds controls for reading and interacting with documents; a canvas-only integration doesn’t include those controls.

    Explore the PDF.js demo

    Key features of PDF.js

    • Client-side rendering — Uses the HTML5 <canvas> element
    • PDF parsing — Loads and interprets PDF documents
    • Viewer interface — Adds navigation and document tools on top of the display layer
    • Active maintenance — Regular updates from Mozilla

    Use cases

    PDF.js fits applications that display existing PDFs: e-readers, embedded viewers, and document portals.

    Viewing a PDF with PDF.js

    The following example renders the first page of a PDF onto a <canvas> element with PDF.js:

    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>PDF.js Example</title>
    </head>
    <body>
    <canvas id="pdf-canvas"></canvas>
    <script src="/pdf.mjs" type="module"></script>
    <script type="module">
    import { GlobalWorkerOptions } from "https://cdn.jsdelivr.net/npm/pdfjs-dist@4.5.136/build/pdf.min.mjs";
    GlobalWorkerOptions.workerSrc =
    "https://cdn.jsdelivr.net/npm/pdfjs-dist@4.5.136/build/pdf.worker.min.mjs";
    const url = "output.pdf"; // Replace with your PDF URL.
    const canvas = document.getElementById("pdf-canvas");
    const ctx = canvas.getContext("2d");
    pdfjsLib
    .getDocument(url)
    .promise.then((pdf) => {
    pdf.getPage(1).then((page) => {
    const viewport = page.getViewport({ scale: 1.5 });
    canvas.height = viewport.height;
    canvas.width = viewport.width;
    page.render({
    canvasContext: ctx,
    viewport: viewport,
    });
    });
    })
    .catch((error) => {
    console.error("Error loading PDF:", error);
    });
    </script>
    </body>
    </html>

    JavaScript PDF viewer PDF.js

    Check out our complete guide to PDF.js for more details on how to use PDF.js in your web application. For developers exploring other JavaScript PDF solutions, our guides on building a React PDF viewer, HTML5 PDF viewers, and JavaScript PDF editors provide comprehensive implementation strategies.

    Nutrient Web SDK: Document tools inside your application

    Nutrient Web SDK provides a viewer and document tools for web applications. Select the components needed for review, forms, editing, or signing, and connect them to your application’s storage and permissions.

    Match capabilities to the required output

    • Return a reviewed PDF. Evaluate annotations and export behavior with the tools reviewers actually use.
    • Save completed forms. Check form handling, required fields, and the application’s submission process.
    • Share a redacted copy. Apply redactions before exporting. Then verify that the sensitive content is absent from the result.
    • Synchronize reviewer changes. Evaluate Instant for shared annotations, including permissions and reconnect behavior.
    • Sign a document. Distinguish a drawn signature from certificate-based signing. Establish who controls the signing key.
    • Work with other formats. Check the selected component’s supported inputs and outputs. Document Authoring, conversion, and AI Assistant have their own requirements.

    Use the Web SDK guides to check the deployment and license required for each operation. Product selection alone doesn’t establish regulatory compliance or application security.

    Example of our JavaScript PDF viewer

    Use an approved test document in the JavaScript PDF viewer demo. Try the action your workflow needs, such as adding a note, and inspect the saved result.

    Viewing a PDF with Nutrient Web SDK

    The following example loads a PDF with Nutrient Web SDK. For other formats and configuration requirements, refer to the viewer documentation.

    <!DOCTYPE html>
    <html>
    <head>
    <script src="https://cdn.cloud.pspdfkit.com/pspdfkit-web@1.6.0/nutrient-viewer.js"></script>
    </head>
    <body>
    <div id="nutrient" style="width: 100%; height: 100vh;"></div>
    <script>
    window.NutrientViewer.load({
    container: "#nutrient",
    document: "document.pdf",
    })
    .then((instance) => {
    console.log("Nutrient loaded", instance);
    })
    .catch((error) => {
    console.error(error.message);
    });
    </script>
    </body>
    </html>

    Nutrient demo

    If you prefer a video tutorial, you can watch our step-by-step guide.

    Nutrient Document Authoring

    If users need to author documents before PDF review, evaluate Nutrient Document Authoring separately. Confirm its format support and licensing for that workflow.

    Key features

    • DOCX editing — Open, modify, and export DOCX files with rich text, tables, and images
    • Multiformat export — Save as DOCX or PDF
    • DocJSON support — Custom workflows and automation
    • Page-based editing — Similar to desktop word processors
    • Client-side editing — Plan asset loading and document persistence for any offline workflow

    What to verify

    Open a representative document, edit it, and inspect the exported DOCX or PDF. Check fonts, tables, and page breaks. Establish how the application will save changes and handle interrupted connections.

    Getting started with Nutrient Document Authoring

    Here’s how to initialize Document Authoring:

    <!DOCTYPE html>
    <html lang="en">
    <head> </head>
    <body>
    <div id="editor" class="my-editor"></div>
    <script src="https://document-authoring.cdn.nutrient.io/releases/document-authoring-1.7.1-umd.js"></script>
    <script>
    (async () => {
    const docAuthSystem = await DocAuth.createDocAuthSystem();
    const editor = await docAuthSystem.createEditor(
    document.getElementById("editor"),
    {
    document:
    await docAuthSystem.createDocumentFromPlaintext("Hello world!"),
    },
    );
    })();
    </script>
    </body>
    </html>

    This creates an in-browser document editor.

    Explore the Nutrient Document Authoring demo to see it in action!

    Adding annotations with Nutrient Web SDK

    Add highlight annotations to PDFs programmatically:

    const rects = NutrientViewer.Immutable.List([
    new NutrientViewer.Geometry.Rect({
    left: 10,
    top: 120,
    width: 200,
    height: 10,
    }),
    new NutrientViewer.Geometry.Rect({
    left: 10,
    top: 150,
    width: 200,
    height: 10,
    }),
    ]);
    const annotation = new NutrientViewer.Annotations.HighlightAnnotation({
    pageIndex: 0,
    rects: rects,
    boundingBox: NutrientViewer.Geometry.Rect.union(rects),
    });
    await instance.create(annotation);

    resulting image showing highlight annotation added to PDF

    Learn more about how to add highlight annotations to PDFs in JavaScript and explore eight common PDF annotation types.

    Adding watermarks with Nutrient Web SDK

    Add watermarks to PDFs using the renderPageCallback option. This overlays user-specific details on each page:

    NutrientViewer.load({
    document: document,
    renderPageCallback: function (ctx, pageIndex, pageSize) {
    ctx.beginPath();
    ctx.moveTo(0, 0);
    ctx.lineTo(pageSize.width, pageSize.height);
    ctx.stroke();
    ctx.font = "30px Comic Sans MS";
    ctx.fillStyle = "red";
    ctx.textAlign = "center";
    ctx.fillText(
    `Generated for John Doe. Page ${pageIndex + 1}`,
    pageSize.width / 2,
    pageSize.height / 2,
    );
    },
    });

    The watermark appears only in the browser view — the original document stays unchanged. Customize text, position, and styling as needed.

    Inserting digital signatures in a PDF with Nutrient Web SDK

    Digitally sign PDF documents using a private key and certificate. This example uses the signDocument method with PKCS#7 signatures:

    <!DOCTYPE html>
    <html lang="en-US">
    <head>
    <meta charset="UTF-8" />
    <title>Nutrient Digital Signature Demo</title>
    <style>
    #viewer {
    width: 100vw;
    height: 100vh;
    }
    </style>
    <script src="https://cdn.cloud.pspdfkit.com/pspdfkit-web@1.6.0/nutrient-viewer.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/node-forge@1.0.0/dist/forge.min.js"></script>
    </head>
    <body>
    <div id="viewer"></div>
    <script>
    NutrientViewer.load({
    document: "sample.pdf",
    container: "#viewer",
    })
    .then((instance) => {
    console.log("Nutrient loaded", instance);
    instance
    .signDocument(null, generatePKCS7)
    .then(() => {
    console.log("Document signed successfully.");
    })
    .catch((error) => {
    console.error("The document could not be signed.", error);
    });
    })
    .catch((error) => {
    console.error("Failed to load viewer:", error.message);
    });
    // Generate a PKCS#7 signature.
    async function generatePKCS7({ fileContents }) {
    const [certificatePem, privateKeyPem] = await Promise.all([
    fetch("cert.pem").then((r) => r.text()),
    fetch("private-key.pem").then((r) => r.text()),
    ]);
    const certificate = forge.pki.certificateFromPem(certificatePem);
    const privateKey = forge.pki.privateKeyFromPem(privateKeyPem);
    const p7 = forge.pkcs7.createSignedData();
    p7.content = new forge.util.ByteBuffer(fileContents);
    p7.addCertificate(certificate);
    p7.addSigner({
    key: privateKey,
    certificate,
    digestAlgorithm: forge.pki.oids.sha256,
    authenticatedAttributes: [
    { type: forge.pki.oids.contentType, value: forge.pki.oids.data },
    { type: forge.pki.oids.messageDigest },
    { type: forge.pki.oids.signingTime, value: new Date() },
    ],
    });
    p7.sign({ detached: true });
    return stringToArrayBuffer(forge.asn1.toDer(p7.toAsn1()).getBytes());
    }
    // Convert binary string to ArrayBuffer.
    function stringToArrayBuffer(binaryString) {
    const buffer = new ArrayBuffer(binaryString.length);
    const view = new Uint8Array(buffer);
    for (let i = 0; i < binaryString.length; i++) {
    view[i] = binaryString.charCodeAt(i);
    }
    return buffer;
    }
    </script>
    </body>
    </html>

    This example illustrates certificate-based signing. Use only disposable test keys with browser-loaded examples; production keys need a protected signing service or appropriate key storage. Verify the signed output and certificate trust separately.

    Sample signed PDF in Adobe Acrobat

    Check out our blog post on how to insert a digital signature in a PDF using JavaScript for more details.

    Limitations of PDF.js

    Assess the version and integration you plan to deploy. A bare canvas example doesn’t demonstrate the full viewer’s capabilities.

    Mozilla documents form filling and editing tools(opens in a new tab) in Firefox’s PDF viewer. These include text, drawing, and highlights. Check which tools are available in your embedded build and whether the exported document retains the required changes.

    For tasks beyond those tools, define the missing operation precisely. Permanent redaction, synchronized review, certificate-based signing, and non-PDF conversion each need their own implementation and evaluation.

    PDF.js vs. Nutrient Web SDK: Compare the document workflow

    Use the same files and acceptance criteria for both options. The following checks help identify whether a product solves the problem.

    Required resultPDF.js evaluationNutrient evaluation
    Read and find informationTest the full viewer’s search, navigation, and text selectionTest the viewer with the same files and devices
    Return comments or completed fieldsCheck the tools in your chosen build and reopen the downloaded PDFTest annotations or forms with the selected components. Then reopen the exported PDF
    Remove sensitive contentIdentify a separate redaction implementation; covering text isn’t removalFollow the mark, apply, export workflow and inspect the output
    Keep reviewers’ changes synchronizedPlan storage and synchronization outside the rendering libraryEvaluate Instant, its server deployment, permissions, and reconnect behavior
    Produce a certificate-signed PDFIdentify a signing implementation and key-management approachEvaluate digital signatures, certificate trust, and protected key storage
    Support the application after releaseReview upstream releases and test integration changesReview release and migration guidance, component licenses, and support terms

    Check performance, access, and accessibility

    Measure loading, search, and scrolling on representative documents and target devices. Test the deployment you intend to operate; a server-backed result doesn’t describe a browser-only setup.

    For either viewer, enforce document authorization in the application and storage service. Opening a password-protected PDF is different from deciding which user may retrieve it.

    Test keyboard operation and assistive technology against the complete application. Document tags, reading order, and interface changes affect the result. Consult Nutrient’s accessibility documentation when evaluating its viewer.

    Pricing and licensing

    PDF.js uses the Apache License 2.0(opens in a new tab). Include hosting, integration, testing, and support arrangements in your evaluation.

    Nutrient uses commercial licensing. Confirm the components and deployment needed for the workflow. Then request pricing for that scope. Don’t assume every feature shown in a demo is included in one license.

    For shared review, account for the server requirements of Instant. If AI Assistant is part of the task, review its separate licensing and prerequisites.

    Compare costs for the same document volume, users, and required output. Avoid treating a fixed development-time estimate as evidence that either option costs less.

    See also

    FAQ

    Yes. Evaluate its viewer and display API against the application’s requirements. Test representative documents, saved output, and supported devices before deciding whether another product is needed.

    Measure the actions users perform: opening the file, scrolling, searching, and saving changes. Use the same documents, device, and network conditions. Record the deployment configuration alongside the results.

    A viewer is one part of the system. Your application must enforce authentication, document permissions, and storage access. Hiding download controls doesn’t prevent a user who receives document data from copying it.

    Review release notes and migration instructions for either product. Test updates against your documents and custom interface before deployment, including saved annotations and forms.

    The full viewer supports form filling and editing tools. Availability depends on the build and version; these tools aren’t included in a canvas-only example. Check the saved PDF against the task your users need to complete.

    Evaluate Nutrient when a required document operation or support arrangement is missing from your current solution. Bring a representative file and a clear pass condition, such as exporting a redacted PDF or reopening a completed form.

    Choosing the right tool for your needs

    Choose one document task and test it from opening the file through saving and reopening the result. Record what worked and where the workflow failed.

    Use the Nutrient demo with an approved test document, or request a trial to evaluate the workflow inside your application. For shared review, redaction, or signing requirements, discuss the workflow with Nutrient and confirm the components and deployment it needs.

    See the detailed PDF.js vs. Nutrient SDK comparison, or browse all product comparisons on the SDK comparison page.

    Hulya Masharipov

    Hulya Masharipov

    Technical Writer

    Hulya is a frontend web developer and technical writer who enjoys creating responsive, scalable, and maintainable web experiences. She’s passionate about open source, web accessibility, cybersecurity privacy, and blockchain.

    Explore related topics

    Try for free Add a complete PDF viewer to your app