How to Print a Page in Angular?
This tutorial will provide example of how to print page in angular. In this article, we will implement a how to print html page in angular. it's simple example of angular print page with css. we will help you to give example of angular print page to pdf. You just need to some step to done angular print pdf from html.
If you need to add print button and give user to print current page in angular then i will show you simple example how to add print button in angular app.
you can easily print a page for pdf in angular 6, angular 7, angular 8, angular 9, angular 10, angular 11, angular 12, angular 13, angular 14, angular 15, angular 16 and angular 17 version app.
So, let's see bellow step and get qr code as like bellow screenshot:
Preview:
src/app/app.component.html
<h1>Angular Print Page Example - ItSolutionStuff.com</h1>
<p>
Start editing to see some magic happen :)
</p>
<button (click)="printPage()">print</button>
src/app/app.component.ts
import { Component, VERSION } from '@angular/core';
@Component({
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: [ './app.component.css' ]
})
export class AppComponent {
name = 'Angular ' + VERSION.major;
printPage() {
window.print();
}
}
src/app/app.component.css
@media print {
button {
display: none;
}
}
Now you can run by bellow command:
ng serve
now you can check it.
I hope it can help you...
Hardik Savani
I'm a full-stack developer, entrepreneur and owner of ItSolutionstuff.com. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Laravel, Angular, Vue, Node, Javascript, JQuery, Codeigniter and Bootstrap from the early stage. I believe in Hardworking and Consistency.
We are Recommending you
- Angular Login with Google Account Example
- Angular Pipe for Array to String Example
- Angular Pipe for Phone Number Example
- Angular Material Input Autocomplete Off Example
- Angular Material Datepicker Disable Specific Dates Example
- How to Create Routing Module in Angular 11?
- Angular 11/10 Google Maps Example Tutorial
- Angular Get Element By Id Value Example
- How to use FormGroup in Angular 11/10?