Angular 9 HTML2PDF.js Tutorial to Convert HTML Table to PDF in Typescript Full Project For Beginners

In order to get started you need to install the below library using the npm command

npm i html2pdf.js

After installing this library you need to copy paste the below code into app.component.html file inside your angular project


<!DOCTYPE html>
<html lang="en">
  <title>Bootstrap Example</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="">
  <script src=""></script>
  <script src=""></script>

<div class="container">
  <h2>Striped Rows</h2>
  <p>The .table-striped class adds zebra-stripes to a table:</p>            
  <table id="table" class="table table-striped">
<button (click)="download()">Download PDF</button>

Now copy paste the below code to app.component.ts file as shown below


Similar Posts:

Leave a Reply

Your email address will not be published. Required fields are marked *