ItSolutionStuff.com

How to Print a Page in Angular?

By Hardik Savani • May 2, 2024
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...

Tags: Angular
Hardik Savani

Hardik Savani

I'm a full-stack developer, entrepreneur, and founder of ItSolutionStuff.com. Passionate about PHP, Laravel, JavaScript, and helping developers grow.

📺 Subscribe on YouTube

We Are Recommending You

Angular Login with Google Account Example

Read Now →

Angular Pipe for Array to String Example

Read Now →

Angular Pipe for Phone Number Example

Read Now →

Angular Material Input Autocomplete Off Example

Read Now →

Angular Material Datepicker Disable Specific Dates Example

Read Now →

How to Create Routing Module in Angular 11?

Read Now →

Angular 11/10 Google Maps Example Tutorial

Read Now →

Angular Get Element By Id Value Example

Read Now →

How to use FormGroup in Angular 11/10?

Read Now →