我无法使用p:打印机标签打印由pe:qrCode生成的二维码。当我将renderMethod设置为img或div时,它根本不会渲染到屏幕上。我没有看到任何关于如何使用该属性的文档。我看过各种关于需要其他jars的帖子,但看起来这是针对较旧的p:bacode功能的。当我直接从浏览器打印时,它会打印,但我打印的是标签,所以我不想打印整个页面。因为它是由客户端上的jQuery生成的,所以我可能需要使用javascript来使其工作。在我走上这些其他道路之前,我只想知道是否有人成功打印了primefaces扩展生成的二维码。
以下是生成二维码但无法打印的代码示例。
<h:form>
<h:panelGrid>
<p:commandButton value="Print QR">
<p:printer target="qrCodeElem"/>
</p:commandButton>
<p:commandButton value="Print QR Panel">
<p:printer target="qrPanelId"/>
</p:commandButton>
<p:commandButton value="Print Hello">
<p:printer target="helloId"/>
</p:commandButton>
<p:panel id="qrPanelId">
<pe:qrCode id="qrCodeElem"
renderMethod="canvas"
text="someqrcode"
label="qrCodeLabel"
size="200"/>
</p:panel>
</h:panelGrid>
<p:panel id="helloId">
<h:outputText value="hello "/>
</p:panel>
</h:form>
</html>发布于 2019-05-23 04:02:38
我可以使用一个简单的print()命令进行打印
<p:commandButton value="print()" onclick="print();"/>我还需要css来告诉它不要打印我不想打印的东西。事实证明,我需要在页面上使用内联CSS。将其放入我的.css文件中并不会忽略我不想打印的部分。这是css
<style type="text/css">
@media print {
.noPrint {
display: none;
}
}
</style>使用styleClass引用它
<h:panelGrid styleClass="noPrint">https://stackoverflow.com/questions/56159252
复制相似问题