惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

P
Proofpoint News Feed
S
SegmentFault 最新的问题
The Last Watchdog
The Last Watchdog
人人都是产品经理
人人都是产品经理
C
Check Point Blog
O
OpenAI News
V
Visual Studio Blog
S
Security @ Cisco Blogs
I
InfoQ
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
T
Troy Hunt's Blog
S
Secure Thoughts
大猫的无限游戏
大猫的无限游戏
Attack and Defense Labs
Attack and Defense Labs
www.infosecurity-magazine.com
www.infosecurity-magazine.com
SecWiki News
SecWiki News
月光博客
月光博客
U
Unit 42
博客园 - Franky
V2EX - 技术
V2EX - 技术
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
腾讯CDC
量子位
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
N
News and Events Feed by Topic
Engineering at Meta
Engineering at Meta
PCI Perspectives
PCI Perspectives
Cisco Talos Blog
Cisco Talos Blog
Google DeepMind News
Google DeepMind News
博客园 - 司徒正美
T
Tailwind CSS Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
TaoSecurity Blog
TaoSecurity Blog
Project Zero
Project Zero
WordPress大学
WordPress大学
A
Arctic Wolf
H
Help Net Security
Blog — PlanetScale
Blog — PlanetScale
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
I
Intezer
雷峰网
雷峰网
Security Latest
Security Latest
N
News and Events Feed by Topic
AI
AI
V
Vulnerabilities – Threatpost
S
Schneier on Security
Vercel News
Vercel News
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC

Inside Nutrient

A guide to the invisible work behind documents Introducing Nutrient Documents for Salesforce: Native document generation and signing Document AI vs. traditional OCR: Choosing between OCR, AI, and hybrid pipelines PDF SDK compliance and security evaluation checklist for enterprise teams (2026) Invariant Corp replaces paper processes with Nutrient Workflow and scales without limits What is process mapping? A complete guide Nutrient vs. Conga Composer for Salesforce document generation (2026) Document routing: How to automate document distribution The CTO’s AI playbook: Why accountability architecture beats orchestration Compliance workflow automation: Why built-in compliance is table stakes Workflow diagrams: Examples, symbols, and how to build one that actually runs Digital forms: Replace paper forms with automated workflows Approval workflow software: How to automate approvals Why document-centric automation is different The CEO’s AI playbook: Why decision architecture beats model selection Nutrient SDK product updates for Q1 2026 PDF redaction verification: How to prove sensitive data is permanently removed What is a VPAT? The complete guide to accessibility conformance reports What is PDF/UA? The accessible PDF standard explained Salesforce eSignatures: Generate, sign, and track documents in one flow Online document viewer: Options, tradeoffs, and how to embed one Document viewer for web apps: React, Vue, Angular (2026) Best document viewers in 2026: A buyer’s guide How to edit a PDF in Python: Add text, images, and annotations Nutrient advances Workflow platform with agentic AI for enterprise-grade speed and consistency in document-heavy operations How to create a Salesforce quote template from opportunity data The business case for accessibility: Five ways it drives enterprise value Python PDF library comparison (2026): 7 libraries for developers Why your AI agent hallucinates PDF table data PDF.js limitations: When to upgrade to a commercial PDF SDK How Subject scaled 5× with Nutrient’s PDF SDK without rebuilding its document layer I replaced our sales training with an AI coach that runs in Slack — here’s what broke Redirecting to: https://securitybuzz.com/cybersecurity-news/why-enterprise-permissions-are-ais-most-dangerous-inheritance/ Nutrient .NET SDK vs. iText Core: Complete comparison for .NET developers DocuVieware: Support’s most frequently asked setup questions Introducing Nutrient Workflow How to convert PDF to Word in C# (.NET) When email and spreadsheets stop working: Work order approval workflows for field teams on the move Compliance with confidence: Why document-centric automation is the foundation of your mission Nutrient expands AI Assistant, automating multistep document workflows inside any application What is document generation? A developer’s guide to PDF generation Document Converter data flow and how real-time watermarks skip the queue PDF/UA compliance guide: Requirements, standards, and best practices Computers still can’t understand you How Athena Intelligence built AI agents for regulated enterprises with Nutrient’s document infrastructure How to convert HTML to PDF (2026): 4 methods from browser print to SDK How to build a document extraction pipeline with Nutrient Vision API OCR vs. intelligent document processing: Choosing the right document extraction engine Beyond OCR: How document intelligence eliminates manual processing in regulated industries Nutrient vs. IronPDF: Complete comparison for .NET developers Nutrient vs. Aspose.PDF: Complete comparison for .NET developers Redirecting to: https://fortune.com/2026/02/19/openclaw-who-is-peter-steinberger-openai-sam-altman-anthropic-moltbook/ Lufthansa Systems uses Nutrient to deliver reliable, scalable PDF rendering for pilots worldwide Nutrient vs. Syncfusion: Complete comparison for .NET developers React’s useTransition: The hook you’re probably using wrong First City Monument Bank streamlines banking processes with Nutrient Workflow Redirecting to: https://www.sdcexec.com/warehousing/automation/article/22957364/nutrient-workflow-automation-the-missing-link-in-supply-chain-efficiency The complete guide to digital signatures: PAdES, CAdES, and XAdES explained Nutrient Python SDK: Production-grade document processing for Python Introducing agentic document editing for web applications with AI Assistant Nutrient vs. QuestPDF: Complete comparison for .NET developers How we fixed the GdPicture license expiration (and what to do if you’re affected) Red team security testing with agentic AI The future of healthcare document automation Best healthcare workflow software compared Nutrient SDK product updates for Q4 2025 How Harvey scaled legal document workflows 50 percent MoM without rebuilding infrastructure HIPAA-compliant document management in hospitals How we optimized rendering performance while handling thousands of annotations in React — Part 2 Automated PII removal with Nutrient API Redirecting to: https://www.devopsdigest.com/2026-low-code-no-code-predictions Redirecting to: https://www.kmworld.com/Articles/Editorial/ViewPoints/Leaders-predict-AI-to-continue-permeating-all-aspects-of-KM-in-2026-172594.aspx What are deep agents and how do they solve complex problems? Whipping up document magic: Your easy-bake recipe for Vue and Nutrient Web SDK 🧁 What I’ve learned about product iteration planning while building SDKs Passwordless document signing: Three-layer security guide New zip folder functionality streamlines file management in Document Automation Server The keyboard shortcuts playbook: Taking control of keyboard events in Nutrient Web SDK From experienced engineer to AI beginner: My unexpected journey AI-assisted manual testing: Handling Safari’s PDF rendering and UI quirks How to keep a 20-year-old SDK up to date How we optimized rendering performance while handling thousands of annotations in React — Part 1 Nutrient announces new executive hires to accelerate next phase of growth High performance UI using web workers Automate document conversion at scale with Python and Nutrient DCS From curiosity to PLG (and AI): My journey to understanding product-led growth Prost to progress: One year as Nutrient Pigeon usage at Nutrient: Bridging native SDKs to Flutter Modernizing CI build servers: How to migrate from Chef to Ansible Unix man pages: AI-friendly documentation since 1971 Consistent hashing for even load distribution Best AI redaction APIs: Complete comparison guide for 2025 Why AI document redaction matters for modern security From coding to coordinating: How AI transformed my workflow What is intelligent document processing (IDP)? A complete guide Enterprise PDF SDKs: Best PSPDFKit (now Nutrient) alternatives Nutrient SDK product updates for Q3 2025 GdPicture support best practices Redacting sensitive data with Nutrient AI redaction API How AI is transforming the customer experience at Nutrient: From instant answers to intelligent support
Generating PDFs in Angular with jsPDF and Nutrient Web SDK
Hulya Masharipov · 2024-05-22 · via Inside Nutrient

Table of contents

    This post will walk you through the process of generating PDFs using Angular — first with a basic approach using jspdf, and then with a more powerful approach using Nutrient Web SDK.

    Generating PDFs in Angular with jsPDF and Nutrient Web SDK

    TL;DR

    This guide compares two approaches to PDF generation in Angular:

    • jsPDF + AutoTable — Fast and easy for generating simple PDFs with tables and text. Ideal for receipts, reports, or exports that don’t require templates or layout precision.
    • Nutrient Web SDK — A more powerful and flexible approach for structured, production-quality documents. Use it to generate PDFs from templates, overlay annotations, insert dynamic content, flatten output, and operate headlessly — all within the browser.

    Use jsPDF for basic exports. Use Nutrient when you need dynamic forms, template-driven layouts, multipage merging, or enterprise-grade workflows.

    What is jsPDF?

    jsPDF(opens in a new tab) is a lightweight JavaScript library that lets you generate PDF files entirely in the browser, without needing any server-side tools. It’s particularly well-suited for simple, static documents like invoices, receipts, certificates, and reports with tables and text.

    jsPDF outputs documents in real time and supports basic features like:

    • Adding text and images
    • Drawing shapes
    • Generating tables (with jspdf-autotable)
    • Downloading files directly from the client

    It’s fast, easy to integrate, and perfect for developers who want a quick solution for exporting content to PDF inside a web app — especially in Angular applications where component-based UI maps nicely to document content.

    However, jsPDF has limitations when it comes to:

    • Template-based workflows
    • Dynamic layout positioning
    • Multipage document assembly
    • Flattening annotations or form elements

    That’s where Nutrient Web SDK shine, and the second half of this tutorial will cover this.

    Prerequisites

    Generating PDFs using jsPDF

    In this section, you’ll focus on using jsPDF(opens in a new tab) to convert web content into PDF format, providing a straightforward approach to PDF generation in your Angular projects.

    Step 1 — Angular installation

    Start by installing Angular CLI(opens in a new tab), a powerful tool for creating and managing Angular projects. Open your terminal and run the following command:

    npm install -g @angular/cli

    This command installs Angular CLI globally on your system, allowing you to create and manage Angular projects.

    Step 2 — Creating a new Angular project

    With Angular CLI installed, you can create a new Angular project. Navigate to the directory where you want to create your project and run the following command:

    ng new angular-pdf-generator

    Angular CLI will prompt you to choose various project configuration options. You can either accept the defaults or customize them according to your preferences.

    After creating the project, navigate to the project directory using the following command:

    Step 3 — Installing the required packages

    To generate PDFs in Angular, you’ll use two libraries: jspdf(opens in a new tab) and jspdf-autotable(opens in a new tab). Install them using npm:

    npm install jspdf jspdf-autotable

    These packages will enable you to create and customize PDFs within your Angular application.

    Step 4 — Creating a PDF generation component

    Angular follows a component-based architecture. Create a component dedicated to PDF generation and run the following command:

    ng generate component pdf-generator

    This command will generate a new component named pdf-generator with associated files for HTML, CSS, and TypeScript.

    Step 5 — Writing the PDF generation code

    Inside the pdf-generator component, open the pdf-generator.component.ts file. In this file, you’ll write the code responsible for generating PDFs:

    import { Component } from "@angular/core";

    import jsPDF from "jspdf";

    import autoTable from "jspdf-autotable";

    @Component({

    selector: "app-pdf-generator",

    templateUrl: "./pdf-generator.component.html",

    styleUrls: ["./pdf-generator.component.css"],

    })

    export class PdfGeneratorComponent {

    generatePDF() {

    // Create a new PDF document.

    const doc = new jsPDF();

    // Add content to the PDF.

    doc.setFontSize(16);

    doc.text("My Angular PDF Generator", 10, 10);

    doc.setFontSize(12);

    doc.text(

    "This is a comprehensive guide on generating PDFs with Angular.",

    10,

    20,

    );

    // Create a table using `jspdf-autotable`.

    const headers = [["Name", "Email", "Country"]];

    const data = [

    ["David", "david@example.com", "Sweden"],

    ["Castille", "castille@example.com", "Spain"],

    // ...

    ];

    autoTable(doc, {

    head: headers,

    body: data,

    startY: 30, // Adjust the `startY` position as needed.

    });

    // Save the PDF.

    doc.save("table.pdf");

    }

    }

    Here, the code defines an Angular component named PdfGeneratorComponent that generates a PDF document with text and a table when a button is clicked. It uses the jsPDF library for PDF creation and jspdf-autotable for building tables within the PDF. The PDF is saved with the name table.pdf.

    Now, open the pdf-generator.component.html file. Add a button element that will trigger the generatePDF() function when clicked. Place this button within your component’s template:

    <div>

    <button (click)="generatePDF()">Generate PDF</button>

    </div>

    Step 6 — Displaying the PDF generation component

    Now that you have your PdfGeneratorComponent, you’ll display it in your Angular application. Open the app.component.html file and add the <app-pdf-generator></app-pdf-generator> tag inside the template:

    <div>

    <!-- Your navigation or other content can go here -->

    <app-pdf-generator></app-pdf-generator>

    </div>

    To incorporate the PdfGeneratorComponent into your Angular application, you need to import it into your app.component.ts file. This is achieved by adding the following import statement at the top:

    import { PdfGeneratorComponent } from "./pdf-generator/pdf-generator.component";

    Next, include PdfGeneratorComponent in the imports array of the @Component decorator. This setup allows you to use the <app-pdf-generator></app-pdf-generator> tag in your application’s HTML template, enabling users to generate PDFs directly from the main interface.

    Here’s how your app.component.ts will look:

    import { Component } from "@angular/core";

    import { RouterOutlet } from "@angular/router";

    import { PdfGeneratorComponent } from "./pdf-generator/pdf-generator.component";

    @Component({

    selector: "app-root",

    standalone: true,

    imports: [RouterOutlet, PdfGeneratorComponent],

    templateUrl: "./app.component.html",

    styleUrls: ["./app.component.css"],

    })

    export class AppComponent {

    title = "angular-pdf-generator";

    }

    Step 7 — Starting the development server

    To see your Angular application in action, start the development server with the following command:

    Your application will be available at http://localhost:4200/. The application will display a Generate PDF button. When this button is clicked, the PDF will be generated as specified in the generatePDF() function.

    resulting pdf

    Angular PDF generation library: Nutrient Web SDK

    While the steps outlined above demonstrate PDF generation using jsPDF, an alternative approach is to use a specialized library like Nutrient Web SDK. This JavaScript library is designed for generating and manipulating PDF documents in Angular-based web applications. Nutrient Web SDK offers a wide range of capabilities, making it a powerful tool for your PDF needs:

    • Create from template — Insert text or images and prefill forms.
    • Generate from images — Convert JPGs, PNGs, or TIFFs into PDF.
    • Assemble documents — Merge multiple PDFs and insert pages.
    • Thumbnail previews — Render pages as thumbnail images.
    • Saving options — Save PDFs to an array buffer, local storage, or a remote server.
    • Headless — Optionally, generate PDFs without displaying the user interface.
    • Client-side — Create PDFs directly in a browser (no server needed).
    • Extendable — Add viewing, forms, signing, annotation, and more.

    Now, you’ll learn how to use Nutrient with Angular to generate PDF documents from predefined PDF templates by merging them with data. This can be incredibly useful for various applications, like generating invoices, contracts, tickets, or any structured documents.

    Step 1 — Setting up your Angular project

    Create a new Angular project:

    ng new nutrient-web-angular-example

    Choose:

    • No for routing
    • CSS for stylesheets

    Then navigate to your project folder:

    cd nutrient-web-angular-example

    Ensure you have an assets folder under src:

    Step 2 — Installing the Nutrient Web SDK

    Add the SDK:

    yarn add @nutrient-sdk/viewer

    Or use npm install @nutrient-sdk/viewer if you prefer.

    Then update your angular.json to expose the SDK assets:

    "assets": [

    "src/assets",

    {

    "glob": "**/*",

    "input": "./node_modules/@nutrient-sdk/viewer/dist/nutrient-viewer-lib/",

    "output": "./assets/nutrient-viewer-lib/"

    }

    ]

    Step 3 — Adding the template and data

    Place your PDF template in the assets folder: src/assets/document.pdf

    Create a JSON file with the data you want to inject: src/assets/data.json

    {

    "company": "Nutrient",

    "companyInfo": "Nutrient Technologies",

    "companyName": "Nutrient Inc."

    }

    Step 4 — Creating and rendering the PDF viewer

    Generate a new component:

    ng generate component pdf-viewer

    Update the HTML template to define a viewer container:

    <div class="pdf-viewer">

    <div id="nutrient-container" style="width: 100%; height: 100vh;"></div>

    </div>

    Step 5 — Populating the PDF with annotations

    Once the PDF is loaded in headless mode, you can inject dynamic data using annotations.

    Here’s how you can do this by creating a TextAnnotation:

    const textAnnotation = new NutrientViewer.Annotations.TextAnnotation({

    boundingBox: new NutrientViewer.Geometry.Rect({

    height: 9.0675,

    left: 60.375,

    top: 37.7399,

    width: 46.905,

    }),

    fontSize: 8,

    text: {

    format: "plain",

    value: data.company,

    },

    pageIndex: 0,

    fontColor: NutrientViewer.Color.RED,

    backgroundColor: NutrientViewer.Color.WHITE,

    });

    await instance.create(textAnnotation);

    • boundingBox — Define the position and size of the text annotation.
    • fontSize — Set the font size.
    • text — Provide the text content within the value property.
    • pageIndex — Specify the page index where you want to overlay the text.

    Repeat this process for other data points that you want to overlay on the document.

    To replace existing placeholder text in your PDF, you can use the SDK’s built-in search method:

    const bbox = (await instance.search("Company Ltd.")).first().rectsOnPage.get(0);

    const dynamicAnnotation = new NutrientViewer.Annotations.TextAnnotation({

    boundingBox: bbox,

    fontSize: 8,

    text: {

    format: "plain",

    value: data.companyName,

    },

    pageIndex: 0,

    fontColor: NutrientViewer.Color.RED,

    backgroundColor: NutrientViewer.Color.WHITE,

    });

    await instance.create(dynamicAnnotation);

    Step 6 — Flattening the annotations

    Once all annotations are added, you can optionally flatten them to make the text part of the PDF content (so users can’t edit them):

    const flattened = await instance.exportPDF({ flatten: true });

    This returns a binary buffer (ArrayBuffer) of the modified PDF, ready to be reloaded in the viewer or downloaded.

    Step 7 — Putting it all together

    Now, update your pdf-viewer.component.ts file with the full flow: load → annotate → flatten → reload.

    93 collapsed lines

    import { Component, OnInit } from "@angular/core";

    import NutrientViewer from "@nutrient-sdk/viewer";

    @Component({

    selector: "pdf-viewer",

    templateUrl: "./pdf-viewer.component.html",

    styleUrls: ["./pdf-viewer.component.css"],

    standalone: true,

    })

    export class PdfViewerComponent implements OnInit {

    async ngOnInit(): Promise<void> {

    const baseUrl = `${location.protocol}//${location.host}/assets/`;

    const searchQuery = "Company Ltd.";

    try {

    const res = await fetch("/assets/data.json");

    if (!res.ok) throw new Error("Failed to fetch data.json");

    const data = await res.json();

    const instance: any = await NutrientViewer.load({

    baseUrl,

    document: "/assets/document.pdf",

    container: "#nutrient-container",

    headless: true,

    });

    const textAnnotation = new NutrientViewer.Annotations.TextAnnotation({

    boundingBox: new NutrientViewer.Geometry.Rect({

    height: 9.0675,

    left: 60.375,

    top: 37.7399,

    width: 46.905,

    }),

    fontSize: 8,

    text: {

    format: "plain",

    value: data.company,

    },

    pageIndex: 0,

    fontColor: NutrientViewer.Color.RED,

    backgroundColor: NutrientViewer.Color.WHITE,

    });

    const textAnnotation2 = new NutrientViewer.Annotations.TextAnnotation({

    boundingBox: new NutrientViewer.Geometry.Rect({

    height: 9.0675,

    left: 478.635,

    top: 37.7399,

    width: 82.695,

    }),

    fontSize: 8,

    text: {

    format: "plain",

    value: data.companyInfo,

    },

    pageIndex: 0,

    fontColor: NutrientViewer.Color.RED,

    backgroundColor: NutrientViewer.Color.WHITE,

    });

    // Search-based bounding box

    const bbox = (await instance.search(searchQuery))

    .first()

    .rectsOnPage.get(0);

    const textAnnotation3 = new NutrientViewer.Annotations.TextAnnotation({

    boundingBox: bbox,

    fontSize: 8,

    text: {

    format: "plain",

    value: data.companyName,

    },

    pageIndex: 0,

    fontColor: NutrientViewer.Color.RED,

    backgroundColor: NutrientViewer.Color.WHITE,

    });

    // Add annotations

    await instance.create([textAnnotation, textAnnotation2, textAnnotation3]);

    // Flatten the PDF

    const flattened = await instance.exportPDF({ flatten: true });

    await NutrientViewer.load({

    baseUrl,

    document: flattened,

    container: "#nutrient-container",

    });

    } catch (error) {

    console.error("PDF population error:", error);

    }

    }

    }

    Step 8 — Using the viewer in your app

    Update your root component to include the viewer:

    import { Component } from "@angular/core";

    import { PdfViewerComponent } from "./pdf-viewer/pdf-viewer.component";

    @Component({

    selector: "app-root",

    standalone: true,

    imports: [PdfViewerComponent],

    templateUrl: "./app.component.html",

    styleUrls: ["./app.component.css"],

    })

    export class AppComponent {

    title = "Nutrient Angular PDF Generator";

    }

    <pdf-viewer></pdf-viewer>

    Step 9 — Run the app

    Start your Angular development server:

    Or use npm start.

    Your browser should now display the PDF template, dynamically populated with data from data.json.

    Summary

    You now have a working Angular app that dynamically:

    • Loads a PDF template
    • Injects structured data with annotations
    • Optionally flattens annotations into the document
    • Displays the final result in the browser

    This approach is fast and scalable and requires no backend processing.

    resulting pdf

    For a detailed explanation, check out our guide on how to generate PDFs from a template using JavaScript.

    Conclusion

    In summary, while basic libraries like jspdf can fulfill simpler PDF generation needs, Nutrient Web SDK excels in scenarios where you require more advanced capabilities, better control, and enhanced functionality. It’s the go-to choice for projects that involve creating structured documents, managing various aspects of PDF files, and empowering your Angular application with a versatile PDF generation and manipulation library.

    To get started, you can either:

    • Start your free trial to test the library and see how it works in your application.
    • Launch our demo to see the viewer in action.

    FAQ

    Install jsPDF using npm with the command npm install jspdf. Then import it into your Angular component and use its methods to create and customize PDF documents.

    Angular’s component-based architecture allows for modular and maintainable code, making it easy to create, manage, and reuse the content that will be converted to PDF.

    Nutrient Web SDK is a powerful JavaScript library designed for generating and manipulating PDF documents in web applications. It provides advanced capabilities such as creating PDFs from templates, converting images to PDFs, assembling documents, rendering thumbnails, and more, making it an ideal choice for complex and feature-rich PDF generation needs.

    Nutrient offers a wide range of advanced features, such as creating PDFs from templates, generating PDFs from images, assembling documents, rendering thumbnails, and more. It provides better control and enhanced functionality, making it suitable for projects requiring complex and structured document creation and management.

    Yes. Nutrient enables you to generate PDFs in headless mode, which means you can create PDFs directly in the browser without displaying any user interface.

    Explore related topics

    Try for free Ready to get started?

    Related SDK articles

    Explore more