我正在尝试使用PrintJS库。它允许您以特定的id为目标并打印包含在该id中的html。我面临的问题是,当我改变屏幕的大小时,它也会改变div的打印大小。它们为您提供了传入css的选项,但并不是所有的更改都会应用。
下面是我的测试用法:
printJS({printable: 'oogles', type: 'html', style: '.modal-header { color: red; width: 100px; } .modal-body { width:100% }'})一些css更改被成功地应用于样式部分,例如color: red,但更改宽度似乎无效。我已经尝试过width: 100%;或任意设置为特定宽度,如width: 100px;
html:
<div id='oogles'>
<div class='modal-header'>wooooooo we are printing some things!</div>
<div class='modal-body'>well we are trying at least</div>
</div>有没有人有使用PrintJS调整打印元素宽度的经验?
谢谢
发布于 2019-05-16 05:26:53
尝试将样式表传递给库。如果HTML没有任何inline style标记,最好由lib禁用样式处理。
例如:
printJS({
printable: 'oogles',
type: 'html',
style: '.modal-header { color: red; width: 100px; } .modal-body { width:100% }'
css: [
'my_stylesheet_1',
'my_stylesheet_2.css'
],
scanStyles: false
})https://stackoverflow.com/questions/56134227
复制相似问题