Angular | Creating PDF Documents

Create App

ng new app
cd app

Additional modules

Install jsPDF for creating PDF documents with JavaScript

npm install       jspdf --save
npm install types/jspdf --save

Demo Page

Create demo page

ng generate component pages/PDF

Add demo page to routing


import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { PDFComponent } from './pages/pdf/component';

const routes: Routes = [
	{	path: '',	redirectTo: 'pdf',	pathMatch: 'full',	},
	{	path: 'pdf',	component: PDFComponent,			},

	imports: [RouterModule.forRoot(routes)],
	exports: [RouterModule],
export class AppRoutingModule {}

Add PDF functionality

Modify pdf.component.html


Modify pdf.component.ts


Add import for jsPDF

import { jsPDF } from 'jspdf';