【问题标题】:Print Multi page JEditorPane html contents in Java在 Java 中打印多页 JEditorPane html 内容
【发布时间】:2011-10-10 05:24:21
【问题描述】:

我用 Java 开发了一个代码,通过将其内容类型设置为 text / html,我将 HTML 内容嵌入到 JEditorPane 中。

但是,此内容会溢出到第二页,依此类推。我知道 JEditorPane 有一个 print() 方法可以打印 JEditorPane 的内容,我知道 JEditorPane 的 print() 方法可以打印 JEditorPane 的所有内容,甚至可以打印多个页面。

我想要的是上、左、右、下边距应该设置为0。

如果我只是在运行时通过在打印前更改打印设置来将边距设置为 0,那将无法正常工作。

因此,我必须实现 Printable 接口。但是当我使用 Printable 接口时,它只允许打印 JEditorPane 的第一页。

当我大量搜索此解决方案时,我在 Google 上找到了此链接;

http://download.oracle.com/javase/tutorial/displayCode.html?code=http://download.oracle.com/javase/tutorial/2d/printing/examples/PaginationExample.java

但这里的问题是我在 JEditorPane 中使用了 html 内容。我不知道如何将链接中提供的上述解决方案与由 HTML 代码组成的 JEditorPane 集成

【问题讨论】:

    标签: java swing printing jeditorpane


    【解决方案1】:

    如果您需要真正的所见即所得,请从此处使用有关分页打印的文章 http://java-sl.com/articles.html

    如果您只需要打印 JEditorPane 的分页内容,请使用此 http://java-sl.com/JEditorPanePrinter.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-04-05
      • 2016-07-16
      • 2021-08-01
      • 1970-01-01
      • 2013-08-27
      • 1970-01-01
      • 2020-04-25
      • 2023-03-07
      相关资源
      最近更新 更多