Я использую htmltopdf (https://wkhtmltopdf.org/) для преобразования HTML-страницы в страницу PDF. Я заметил, что страница выглядит хорошо на веб-странице, а также при печати с использованием функции печати в браузере.
Если я конвертирую тот же HTML, используя htmltopdf javascript, а затем распечатаю. Сгенерированный 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>
Есть идеи, почему это происходит ...
Заранее спасибо ...