JavaFx:webview打印,适合100%的大小 [英] JavaFx: webview print with fit to size 100%

查看:250
本文介绍了JavaFx:webview打印,适合100%的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

要打印我的html页面,我使用以下代码:

To print my html page I use the following code:

  PrinterJob job = PrinterJob.createPrinterJob();
   if (job != null && job.showPrintDialog(null)){
      webView.getEngine().print(job);
      job.endJob();
  }

问题是webview会改变打印页面的比例。例如,当我在IE中打印这个html页面时,大小为100%,我得到16.8厘米。当我在我的java应用程序中打印时,我得到了11.4cm。我在pt中设置的html文件中的大小 - 我的宽度是475pt(A4宽度= 595pt,所以475pt = 16.8cm)。如何在webview中打印,适合100%的尺寸?有可能吗?

The problem is that webview changes the scale of printing page. For example, when I print this html page in IE with fit to size 100% I get 16.8 cm. When I print in my java application I get 11.4cm. The size in html file I set in pt - my width is 475pt(A4 width=595pt,so 475pt=16.8cm). How to print in webview with fit to size 100%? Is it possible to do?

P.S。如果我理解错误 - >我问的是错误的问题,请纠正我。

P.S. If I understand something wrong->I am asking wrong question, please correct me.

推荐答案

已经有错误报告可能与您的问题有关。
https://bugs.openjdk.java.net/browse/JDK-8088509
据我所知,到目前为止还没有解决方案。
Michael

There already is a bug report which may be related to your issue. https://bugs.openjdk.java.net/browse/JDK-8088509 As far as I can tell there is no solution so far. Michael

这篇关于JavaFx:webview打印,适合100%的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆