从浏览器打印到标签打印机,设置可打印区域的尺寸

Printing from browser to label printer, setting the dimensions of the printable area

我想要控制从浏览器打印到 2.4"x4" 标签时的显示方式。

目前,当我使用像 Pages(苹果版 Microsoft Word)这样的文字处理应用程序时,我可以将文档大小设置为 2.4" x 4" 并点击打印,我知道所有内容都适合标签。我试图在浏览器中实现同样的目标。

我不确定,但我在想当我当前从浏览器打印时它包括很多白色 space,并试图将其全部缩放以适合标签,这会扭曲内容。

我对前端 Web 开发还很陌生,所以我正在寻找有关如何定义可打印区域的指导。我宁愿这一切都发生在浏览器中,但我考虑过让网站生成正确尺寸的 PDF,因为我认为这将像 Pages 一样处理打印。

希望这是有道理的!

虽然有适合分页格式的样式功能,但 Web 是围绕连续 (paged-less) 文档构建的。正因为如此,分页格式化很麻烦。例如,您无法从文档中指定文档页面尺寸。相反,打印机对话框提供了页面大小的选择,呈现引擎会尝试将您的内容适合该大小的页面。

CSS has a module for paged media which includes: page-break-after, page-break-before, and page-break-inside for telling the engine how block elements should break across pages; @page sections for specifying CSS that applies only to paged environments; and :blank, :first, :left, and :right psuedo-elements 用于创建绑定到特定页面的规则。