我有一个应用程序,允许用户编辑在线名片。一旦用户输入了他们的详细信息,我想下载名片为pdf。我的问题是,当我下载的pdf,它需要一个标准的A4大小,而不是我的名片大小,使它难以直接打印。如何定义pdf维度来匹配我的名片的大小?请检查这个链接
http://thecardguys.co.ke/modules/onecard.php?cardid=100&side=1
我尝试了以下css规则
#printarea {
position: relative;
margin: 0 auto;
width: 400px;
}
body,html
{
width:400px;
margin: 0 auto;
}
发布于 2015-08-24 16:14:29
您必须再设置几个CSS位,以确保打印是正确的。
@page {
size: 91.44mm 53.34; // set appropriately
margin: 0;
}
@media print {
html, body {
width: 91.44mm; // set appropriately
height: 53.34mm; // set appropriately
}
/* ... the rest of the rules ... */
}
这将告诉浏览器它应该到达的页面大小以及实际页面在mm
中需要的宽度和高度。
您还需要记住的是,要打印的页面大小将始终与加载打印机的纸张相同。
https://stackoverflow.com/questions/32186310
复制相似问题