我正在使用htmltopdf(https://wkhtmltopdf.org/)将HTML页面转换为PDF页面。我观察到Page在网页上以及在使用浏览器打印功能进行打印的情况下看起来都不错。
如果我使用htmltopdf javascript转换相同的HTML,然后打印。生成的PDF将缩小。
我在这里添加了html代码供您参考。为了进行测试,您可以将html作为输入提供给https://html2pdf.com/在线转换器。
这是HTML代码。
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>HTML & CSS Avery Labels (5160) by MM at Boulder Information Services</title>
<link rel="stylesheet" type="text/css" >
<style>
body {
width: 8.5in;
margin: 0in .1875in;
}
.label{
/* Avery 5160 labels -- CSS and HTML by MM at Boulder Information Services */
width: 2.025in; /* plus .6 inches from padding */
height: .875in; /* plus .125 inches from padding */
padding: .125in .3in 0;
margin-right: .125in; /* the gutter */
float: left;
text-align: center;
overflow: hidden;
/* outline doesn't occupy space like border does */
outline: 1px dotted;
}
.page-break {
clear: left;
display:block;
page-break-after:always;
}
</style>
</head>
<body>
<div class="label"><img src="https://boulderinformationservices.files.wordpress.com/2011/08/barcode_sample.png" /><br>Human readable</div>
<div class="label"><img src="https://boulderinformationservices.files.wordpress.com/2011/08/barcode_sample.png" /><br>Human readable</div>
<div class="label"><img src="https://boulderinformationservices.files.wordpress.com/2011/08/barcode_sample.png" /><br>Human readable</div>
<div class="label"><img src="https://boulderinformationservices.files.wordpress.com/2011/08/barcode_sample.png" /><br>Human readable</div>
<div class="label"><img src="https://boulderinformationservices.files.wordpress.com/2011/08/barcode_sample.png" /><br>Human readable</div>
<div class="label"><img src="https://boulderinformationservices.files.wordpress.com/2011/08/barcode_sample.png" /><br>Human readable</div>
<div class="label"><img src="https://boulderinformationservices.files.wordpress.com/2011/08/barcode_sample.png" /><br>Human readable</div>
<div class="label"><img src="https://boulderinformationservices.files.wordpress.com/2011/08/barcode_sample.png" /><br>Human readable</div>
<div class="label"><img src="https://boulderinformationservices.files.wordpress.com/2011/08/barcode_sample.png" /><br>Human readable</div>
<div class="label"><img src="https://boulderinformationservices.files.wordpress.com/2011/08/barcode_sample.png" /><br>Human readable</div>
</body>
</html>
知道为什么会发生...
预先感谢...