简体   繁体   English

使用自动分页符打印 WebView/WebEngine

[英]Print WebView/WebEngine with auto page break

I have some HTML text like我有一些 HTML 文本,例如

<h1>lorem... </h1>
<b> Lorem text going on...

and I want to print the HTML on any printer我想在任何打印机上打印 HTML

WebEngine webEngine = WebView.getEngine();
webEngine.loadContent(html);
webEngine.print(javafx.PrinterJob);

But the result is one page cut off at the botten... The print function of chrome has the functionality I mean.但结果是在botten 处剪掉了一页…… chrome 的打印功能具有我的意思。

Okay.好的。 I get this solution for my case.我为我的案例得到了这个解决方案。 I'm using a JEditorPane我正在使用JEditorPane

 JEditorPane editorPane = new JEditorPane();
 editorPane.setContentType("text/html");
 editorPane.setText("<html>...");
 editorPane.print(null, null, false, javax.print.PrintService, null, false);

And in now there are auto page breaks现在有自动分页符

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM