V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
sonders
V2EX  ›  问与答

Js 如何设置谷歌浏览器打印的默认边距,纸张大小

  •  
  •   sonders · 2022-01-10 11:10:36 +08:00 · 720 次点击
    这是一个创建于 837 天前的主题,其中的信息可能已经有所发展或是发生改变。

    如题,现在想要实现使用 JS 来自动帮用户设置好打印时的纸张大小,默认边距及缩放。
    已知,css 中 @Page { size: landscape}; 可以控制打印时的方向。

    5 条回复    2022-01-10 17:25:01 +08:00
    ccyu220
        1
    ccyu220  
       2022-01-10 11:59:28 +08:00
    ```cs
    @page {
    /* pager margin */
    margin: 1cm;

    /* 1 value: height = width */
    size: 6in;

    /* 2 values: width then height */
    size: 4in 6in;

    /* Keyword values for absolute size */
    size: A4;
    }
    ```
    ccyu220
        2
    ccyu220  
       2022-01-10 12:00:29 +08:00
    怎么复制过来变成这样了...
    vanton
        3
    vanton  
       2022-01-10 12:02:15 +08:00
    @ccyu220 #2

    回复不支持代码格式化,挺难用的。
    sonders
        4
    sonders  
    OP
       2022-01-10 13:37:09 +08:00
    @ccyu220 感谢,我尝试下
    learningman
        5
    learningman  
       2022-01-10 17:25:01 +08:00 via Android
    有打印的媒体查询的
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2888 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 14:24 · PVG 22:24 · LAX 07:24 · JFK 10:24
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.