I tried almost all npm packages to generate HTML content in PDF. this or that function does not work, because the contents of the table are damaged or do not load images. After so many attempts, I found Kendo UI Angular PDF Export. Kendo Angular export user interface worked for many functions besides dynamic image loading. So, I was looking to solve this problem, but, unfortunately, I did not find the proper documentation to solve this problem. After so many tracks, I solved it.
Follow the steps below to generate HTML content in PDF using the Kendo UI Angular export npm package.
Download and install the package.
npm install --save @ progress / kendo-angular-pdf-export @ progress / kendo-drawing
For Angular 6, install the rxjs-compat package. For more information, see the article on upgrading to Angular 6.
npm install --save rxjs-compat @ 6
For Angular 5 or earlier, install RxJS v5. 5+.
npm install --save rxjs@ ^ 5.5
After installation, import PDFExportModule into the root or function module of the application.
import { NgModule } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; import { PDFExportModule } from '@progress/kendo-angular-pdf-export'; import { AppComponent } from './app.component'; @NgModule({ bootstrap:[AppComponent], declarations: [AppComponent], imports:BrowserModule, PDFExportModule] }) export class AppModule { }
For a complete working example, please read my blog at https://www.stackquery.com/articles/how-to-generate-pdf-in-angular-with-repeated-headers-images-and-watermark/75 .
The above blog example allows large dynamic tables with automatically repeating headings on each page and large dynamic images, and also allows the use of page breaks between pages.
Note. The above example does not take screenshots such as jsPDF or other npm packages. The above example is very efficient; it takes only less than 200 KB to create high-resolution, high-speed PDFs.