代码之家  ›  专栏  ›  技术社区  ›  Wienczny

当使用飞碟打印时,在prolog中不允许来自DOM创建的文档的内容

  •  1
  • Wienczny  · 技术社区  · 14 年前

    我想用我的飞碟打印一些文字( https://xhtmlrenderer.dev.java.net

    DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
    DocumentBuilder documentBuilder;
    documentBuilder = documentBuilderFactory.newDocumentBuilder();
    Document document = documentBuilder.newDocument();
    Element html = document.createElement("html");
    document.appendChild(html);
    Element body = document.createElement("body");
    html.appendChild(body);
    for (String paragraph : paragraphs) {
        Element paragraphTag = document.createElement("p");
        paragraphTag.setTextContent(paragraph);
        body.appendChild(paragraphTag);
    }
    XHTMLPanel panel = new XHTMLPanel();
    panel.setDocument(document);
    
    print(new XHTMLPrintable(panel));
    

    print方法获取一个Printable并将其放入PrintJob。

    1 回复  |  直到 14 年前
        1
  •  0
  •   Wienczny    14 年前

    XHTMLPrintable不能处理RAM中的文档。XHTMLPrintable尝试使用给定的文档生成URL。然后将此“url”用作Graphics2DRenderer-fail的文档。

    推荐文章