admin管理员组文章数量:1023263
I have an application that allows users to edit an online business card. once the user has entered their details, I would like to download the business card as pdf. my issue is that when I download the pdf, it takes a standard A4 size instead of the size of my business card making it difficult to print directly. How can I define the pdf dimension to match the size of my business card? Please check this link
.php?cardid=100&side=1
I tried the following css rule
#printarea {
position: relative;
margin: 0 auto;
width: 400px;
}
body,html
{
width:400px;
margin: 0 auto;
}
I have an application that allows users to edit an online business card. once the user has entered their details, I would like to download the business card as pdf. my issue is that when I download the pdf, it takes a standard A4 size instead of the size of my business card making it difficult to print directly. How can I define the pdf dimension to match the size of my business card? Please check this link
http://thecardguys.co.ke/modules/onecard.php?cardid=100&side=1
I tried the following css rule
#printarea {
position: relative;
margin: 0 auto;
width: 400px;
}
body,html
{
width:400px;
margin: 0 auto;
}
Share
Improve this question
edited Aug 24, 2015 at 15:48
Sid
4636 silver badges14 bronze badges
asked Aug 24, 2015 at 15:39
jonahjonah
2134 silver badges16 bronze badges
0
1 Answer
Reset to default 5You'll have to set a couple more CSS bits to ensure that your print is correct.
@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 ... */
}
This tells the browser what page size it should go to and what width and height in mm
is required of the actual page.
What you also need to remember is that the page size to print will always be the same as the paper that the printer is loaded with.
- CSS3 Page Documentation
I have an application that allows users to edit an online business card. once the user has entered their details, I would like to download the business card as pdf. my issue is that when I download the pdf, it takes a standard A4 size instead of the size of my business card making it difficult to print directly. How can I define the pdf dimension to match the size of my business card? Please check this link
.php?cardid=100&side=1
I tried the following css rule
#printarea {
position: relative;
margin: 0 auto;
width: 400px;
}
body,html
{
width:400px;
margin: 0 auto;
}
I have an application that allows users to edit an online business card. once the user has entered their details, I would like to download the business card as pdf. my issue is that when I download the pdf, it takes a standard A4 size instead of the size of my business card making it difficult to print directly. How can I define the pdf dimension to match the size of my business card? Please check this link
http://thecardguys.co.ke/modules/onecard.php?cardid=100&side=1
I tried the following css rule
#printarea {
position: relative;
margin: 0 auto;
width: 400px;
}
body,html
{
width:400px;
margin: 0 auto;
}
Share
Improve this question
edited Aug 24, 2015 at 15:48
Sid
4636 silver badges14 bronze badges
asked Aug 24, 2015 at 15:39
jonahjonah
2134 silver badges16 bronze badges
0
1 Answer
Reset to default 5You'll have to set a couple more CSS bits to ensure that your print is correct.
@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 ... */
}
This tells the browser what page size it should go to and what width and height in mm
is required of the actual page.
What you also need to remember is that the page size to print will always be the same as the paper that the printer is loaded with.
- CSS3 Page Documentation
本文标签: javascriptGenerate custom size pdf using browser print functionStack Overflow
版权声明:本文标题:javascript - Generate custom size pdf using browser print function - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745502832a2153469.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论