在Chrome的打印设置CSS中强制使用A5纸张尺寸 [英] Force A5 Paper-size in Chrome's print settings CSS
问题描述
我必须在一个Web应用程序中打印出2个html页面. 第一页必须以 A5 尺寸打印出来, 第二个 A4 大小. 我试图强制使用A5打印设置
I've to print out 2 html pages in a web-app. The first page must be printed out in A5 size , the second in A4 size. I tried to force the a5 print settings with
@media print{
@page {
size: a5 landscape;
margin: 0;
}
}
和其他文件中的a4打印设置,
and the a4 print settings in the other file with
@media print {
@page {
size: a4;
margin: 0;
}
}
A4工作正常, 但是,如果我尝试打印A5页面,则纸张尺寸不会改变 (但已设置横向模式)
A4 is working fine, but if I try to print the A5 page , paper-size doesn't change (but landscape mode is set)
推荐答案
您可以使用paper-css库,因为它将帮助您轻松定义纸张尺寸 通过paper-css lib 加载CSS文件
You could uset paper-css library as it will help you easily define the paper size by paper-css lib load the css file
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/paper-css/0.3.0/paper.css">
然后在<head>
部分设置样式
<style>@page { size: A5 }</style>
然后将主体类设置为A5
,如下所示
then set the body class to A5
like the following
<!-- Set "A5", "A4" or "A3" for class name -->
<!-- Set also "landscape" if you need -->
<body class="A5">
<!-- Each sheet element should have the class "sheet" -->
<!-- "padding-**mm" is optional: you can set 10, 15, 20 or 25 -->
<section class="sheet padding-10mm">
<!-- Write HTML just like a web page -->
<article>This is an A5 document.</article>
</section>
</body>
有关更多信息,请点击下面的链接 https://github.com/cognitom/paper-css
for more information follow the link below https://github.com/cognitom/paper-css
这篇关于在Chrome的打印设置CSS中强制使用A5纸张尺寸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!