Dynamically set the printed page size using ‘@page’

I want to print labels of 2 sizes – 3X2inches and 3x3inches.

Bydefault I have set the label print page size as 3x2inches in styles.scss (Global file).

@page {
    size: 3in 2in;
}

I now want to select the 3x3in label. After selecting the dropdown option and clicking the ‘Print’ button, how can I dynamically change the printed page size in typescript or CSS using class?

// Want to set new page size dynamically to following
@page {
    size: 3in 3in;
}