How to print landscape just in one component in angular?

I have an Angular project that uses window.print() to print different pages. But I want only one page to be printed lanscape. I know that I should use the following code, but even though I give this code only to the style of one component, it is applied to all components.

when I wrote this code in style.css of that component , it is applied to all components.

@media print{
    @page{
        size:landscape;
}

and when I wrote this code in main.css, it didn’t work.

@media print{
.class-name{
    @page{
        size:landscape;
    }
}

Please help me.