To complete @ester44's post, which works very well, you can put in the file, apart from @media print a disply: none for the header and footer that you don't want to see on the web page.
Example:
.header, .header-cover, .footer {
display: none;
}
@media print {
.header, .footer {
position: fixed;
}
.header, .header-cover {
display:flex;
}
.header {
top: 100%;
}
.header, .header-space {
height: 5rem;
}
.footer, .footer-space {
height: 4rem;
}
.footer {
bottom: 0;
}
}