rm-ng-pdf-export

July 12, 2026 · View on GitHub

npm version Production ready license Angular support range Ivy compatible Standalone API AOT compatible SSR compatible Strict TS Tree-shakable No side effects Linting Tests Coverage Accessibility compliant API docs Examples No dependencies total downloads Last update Maintained SemVer Open issues GitHub stars

See It In Action

rm-ng-pdf-export Demo

Export any HTML element to PDF with customizable settings!


rm-ng-pdf-export is a lightweight, flexible, and tree-shakable Angular library for generating and exporting ultra-high-quality PDFs from HTML content with smart page breaking and crystal-clear rendering. Built with modern Angular, it seamlessly integrates with your application using services, directives, and components.


Note:

This library is intended for generating non-editable, read-only PDFs.

If you need to create structured, searchable, and editable PDFs, please use our other library: @codewithrajat/rm-ng-structure-pdf.


Table of Contents


Live Demo & Playground

StackBlitz Demo

Interactive Playground
Try all features live in your browser
GitHub Examples

Complete Examples
Copy-paste ready code samples
npm Package

npm Registry
Install and view package details
GitHub Repository

Source Code
Star, fork, and contribute

Quick Start

Installation

npm install @codewithrajat/rm-ng-pdf-export

Basic Usage

main.ts Configuration

import { PDF_EXPORT_CONFIG, PdfExportConfig } from '@codewithrajat/rm-ng-pdf-export';

export const appConfig: ApplicationConfig = {
  providers: [
    provideRouter(routes),
      {
      provide: PDF_EXPORT_CONFIG,
      useValue: {
        pageSize: 'A4',
        orientation: 'portrait',
        filename: 'default.pdf',
        openInNewTab: false,
      } as PdfExportConfig,
    }
  ]
};

Set up component

import { PdfExportService } from '@codewithrajat/rm-ng-pdf-export';

@Component({
  selector: 'app-example',
  template: `
    <div #content>
      <h1>Hello PDF!</h1>
      <p>This content will be exported to PDF</p>
    </div>
    <button (click)="exportPdf()">Export PDF</button>
  `
})
export class ExampleComponent {
  private readonly pdfService: PdfExportService  = inject(PdfExportService)
  content = viewChild<ElementRef<HTMLDivElement>>('content');

  exportPdf() {
    const contentEl = this.content()?.nativeElement;
    if (!contentEl) {
      return;
    }
    this.pdfService.exportHtml(contentEl, {
      filename: 'my-document.pdf',
      pageSize: 'A4',
      orientation: 'portrait'
    });
  }
}

Features

  • Ultra-High-Resolution Output: 3x html2canvas scaling + 4x canvas resolution
  • Smart Page Breaking: Intelligent content boundary detection
  • Multiple Page Sizes: A3, A4, A5, Letter, Legal, and more
  • Portrait/Landscape: Dynamic orientation support
  • Angular 14-21 Support: Compatible with modern Angular versions
  • Tree-shakable: Optimized bundle size
  • TypeScript: Full type safety
  • Multiple APIs: Service, Directive, and Component approaches

Live Examples

Explore our comprehensive examples to see the library in action:

View All Examples →


Installation & Setup

For detailed installation instructions, see our Installation Guide.


Usage

For comprehensive usage examples and API documentation, see our Usage Guide.


Changelog

See CHANGELOG.md for release history and updates.


Latest Release

Check the releases page for the most recent version and updates.


License

This project is licensed under the MIT License - see the LICENSE file for details.

TL;DR: You can use this library freely in commercial and personal projects.

MIT License Summary

You can:

  • Use commercially
  • Modify the code
  • Distribute
  • Use privately

You must:

  • Include the license and copyright notice

You cannot:

  • Hold the author liable

FAQ

Q: What is rm-ng-pdf-export?

A: rm-ng-pdf-export is an Angular library that converts rendered HTML content into high-quality, non-editable PDF files using image-based rendering and smart page breaking.

Q: Which Angular versions are supported?

A: The library supports modern Angular versions, including Angular 14 through 22, with Ivy, AOT, SSR, and standalone-compatible APIs.

Q: Is the generated PDF editable or searchable?

A: No. This library creates image-based PDFs, so the output is read-only and non-editable. Use @codewithrajat/rm-ng-structure-pdf if you need structured, searchable, or editable PDFs.

Q: Can I export multiple pages?

A: Yes. The library supports multi-page PDF generation based on the target page size, orientation, margins, and content height.

Q: Can I customize page size and orientation?

A: Yes. You can choose common page sizes such as A3, A4, A5, Letter, and Legal, and switch between portrait and landscape orientations.

Q: Does it work with images, charts, and canvas content?

A: Yes. Most HTML content can be exported, including images, charts, and canvas-based visualizations. External images must be loaded correctly and follow browser CORS requirements.

Q: Why are some images or fonts missing in the PDF?

A: This usually happens when assets are not fully loaded before export or when external resources block browser rendering. Load images before exporting and ensure CORS is configured for remote assets.

Q: Can I export Angular forms?

A: Yes. You can export any rendered Angular template, including forms. Make sure the form state is finalized before calling the export method.

Q: Can I add headers, footers, or page numbers?

A: Yes, include them as part of the HTML content you export. For repeated headers or footers, create a layout inside the export target.

Q: How do I handle very large documents?

A: Large documents can increase export time and PDF size. Use lower scale values, reduce image sizes, split content into sections, or batch export pages when needed.

Q: Does it work on mobile browsers?

A: Yes, it works on modern mobile browsers. Performance depends on device memory, content size, and image resolution.

Q: Can I use this in commercial projects?

A: Yes. The library is MIT licensed and can be used in personal and commercial projects.


Browser Compatibility

Supported Browsers

BrowserVersionSupport LevelNotes
Chrome80+Full SupportRecommended browser
Firefox75+Full SupportWorks perfectly
Safari13+Full SupportiOS and macOS
Edge80+Full SupportChromium-based
Opera67+Full SupportWorks well
Samsung Internet12+Full SupportMobile support

Mobile Support

  • iOS Safari 13+
  • Chrome for Android 80+
  • Samsung Internet
  • All mobile browsers with modern JavaScript support

Download Behavior by Platform

PlatformBehavior
Desktop Chrome/Firefox/EdgeDirect download to Downloads folder
Desktop SafariMay prompt for download location
iOS SafariOpens download manager
Android ChromeDownloads to Downloads folder
Mobile SafariShows share sheet with save option

Not Supported

  • Internet Explorer (all old versions)
  • Very old mobile browsers (pre-2019)

Statistics

npm downloads npm version GitHub issues GitHub stars License


Support This Project

If rm-ng-pdf-export has helped you build better Angular applications, please consider:

If this library has saved you development time and helped create amazing image sliders in your projects, please consider giving it a star!

Why star this repo?

  • Help other developers discover this lightweight, optimized solution
  • Support continued development and improvements
  • Show appreciation for free, quality tools
  • Boost visibility in the Angular community
  • Increases visibility in the Angular community
  • Supports ongoing development and maintenance
  • Encourages more open-source contributions
  • Helps other developers find quality tools

Want More Quality Libraries?

This is just one of several useful libraries I've created. Explore my other Angular & web development libraries that might solve your next challenge:

  • Utility libraries for common development tasks
  • UI components for better user experiences
  • Performance tools for optimization
  • Mobile-friendly solutions for responsive apps

Found them helpful? A star on each repo you find useful helps tremendously! It takes just one click but means the world to open-source maintainers.

GitHub GitHub followers GitHub stars


Support and Community

Getting Help

Need assistance? We're here to help!

Support ChannelLinkBest For
Bug ReportsReport BugTechnical issues
Feature RequestsRequest FeatureNew features
DiscussionsJoin DiscussionGeneral questions
Emailmr.rajatmalik@gmail.comDirect support

Documentation

Community

  • Star the repository to show support
  • Watch for updates and new releases
  • Share your use cases and feedback
  • Contribute code or documentation

Stay Updated

  • Follow the project on GitHub
  • Star the repository for updates
  • Watch for new releases

Acknowledgements

This library was created to provide a simple, effective solution for PDF export in Angular applications.

Special thanks to:

  • Angular Team - Amazing framework and ecosystem
  • html2canvas - Excellent HTML rendering library
  • pdf-lib - Powerful PDF generation library
  • Contributors - Thank you for making this library better
  • Community - For feedback and feature requests

Other Libraries

UI Components

LibraryDescriptionnpm Link
rm-range-sliderLightweight two-thumb range slider with tooltips and color customizationnpm
rm-ng-range-sliderAngular-specific version of the dual range slidernpm
rm-carouselSimple, responsive carousel componentnpm
rm-image-sliderMinimal image slider with smooth transitionsnpm
rm-ng-star-ratingConfigurable Angular star rating component with readonly modenpm
@codewithrajat/rm-ng-typeaheadAngular autocomplete/typeahead component with search suggestions and keyboard navigationGitHub
@codewithrajat/rm-ng-editorRich text editor component for Angular applications with customizable toolbar supportGitHub

PDF & Export Libraries

LibraryDescriptionnpm Link
rm-ng-export-to-csvExport JSON data to CSV with zero dependenciesnpm
@codewithrajat/rm-ng-pdf-exportImage-based PDF export tool for Angular applicationsnpm
@codewithrajat/rm-ng-structure-pdfGenerate structured PDFs for reports, invoices, or documentsnpm
@codewithrajat/rm-ng-pdf-viewerAngular PDF viewer component with zoom, navigation, and document rendering supportGitHub

Chrome Extension

LibraryDescriptionLink
quickocrChrome extension that extracts text from images using OCR technologyGitHub
readLoudeChrome extension that read you web page loude e.g article etc.GitHub
ai-assistant-replyAI Chrome extension to auto generate reply on linked in posts.GitHub

VS Code Extension

LibraryDescriptionLink
dead-css-cleanerVS Code extension for identifying and cleaning unused CSS stylesGitHub
file-coverage-insightVS Code extension for auto generated component file coverage automatelly on open.GitHub

Desktop Applications - All Plateform

LibraryDescriptionLink
deepworkCross-platform productivity application for focus sessions and deep work trackingGitHub
JsSandboxCross-platform JavaScript playground and code execution environmentGitHub

Device Detection

LibraryDescriptionnpm Link
rm-ng-device-detectionDetect device type, OS, and browser in Angularnpm

Notifications

LibraryDescriptionnpm Link
rm-pushnotifyLightweight push-style toast notification utilitynpm
@codewithrajat/rm-toast-notificationCross-platform toast and desktop notification library for web, Angular, and desktop applicationsGitHub

Layout & Dynamic Rendering

LibraryDescriptionLink
rm-ng-dynamic-layoutDynamic layout rendering engine for Angular applications using JSON-driven UI configurationGitHub

Developer Tools & Extensions

LibraryDescriptionLink
rm-colorful-console-loggerStructured and colorized console logging utility for developersnpm

Meta & Personal Branding

LibraryDescriptionnpm Link
about-rajatDeveloper portfolio package for branding and quick personal infonpm

All Packages

Browse all my packages:


Author

Rajat Malik

Full‑Stack Developer and Frontend Architect at Siemens with 14+ years building scalable enterprise platforms, specializing in micro‑frontends, AI‑native development, React, and Angular.
Author of 10+ open‑source libraries and 100+ technical articles, driving innovation through developer‑friendly tools, performance optimization, and AI‑assisted workflows.

GET IN TOUCH

SOCIAL PRESENCE

CONTENT & WRITING


Made with care and love by Rajat Malik for the Angular community

Star on GitHubView on npmReport IssueTry Demo

Made with dedication by Rajat Malik