how did not zoom content on printing when browser zoom?

ぐ巨炮叔叔 提交于 2019-12-13 04:19:19

问题


how did not zoom content on printing when browser zoom? on zoom browser printing(use iframe) should not changed i try:

document.body.style.transformOrigin = 'top left';
document.body.style.transform = 'scale(' + scale + ')';

but it's not correctly when page very long


回答1:


This could help to disable zooming overall.

<meta content='width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;' name='viewport'>



回答2:


I use next code:

const updateSizePrintPage = () => {
        let scale = 1 / window.devicePixelRatio;
        document.getElementById('print-page').style.transform = 'scale(' + scale + ')';
        document.getElementById('print-page').style.transformOrigin = 'top left';
      };
 window.addEventListener('resize', updateSizePrintPage )

and it works for me.



来源:https://stackoverflow.com/questions/46673904/how-did-not-zoom-content-on-printing-when-browser-zoom

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!