refer this link https://medium.com/@Idan_Co/the-ultimate-print-html-template-with-header-footer-568f415f6d2a. it's helpful to avoid the overflow