Printable
public class XHTMLPrintable
extends org.xhtmlrenderer.simple.XHTMLPrintable
XHTMLPrintable
to set document margins to the printer's margins.
Seems to work nicely on Windows, not yet so much on Linux.
Currently also converts form elements to text items. TODO make this configurable.
Originally, this code was based on a thread on xhtmlrenderer's users mailing list.
TODO This code is not completely finished but seems to work for me; be sure to test for your case.
NO_SUCH_PAGE, PAGE_EXISTS
Constructor | Description |
---|---|
XHTMLPrintable(org.xhtmlrenderer.simple.XHTMLPanel panel) |
Modifier and Type | Method | Description |
---|---|---|
int |
print(Graphics g,
PageFormat pf,
int page) |
|
static Document |
translateFormElements(Document origDoc) |
Replace form elements with text.
|
public int print(Graphics g, PageFormat pf, int page)
This method fixes the margins just before layouting, and converts form
elements to text items using translateFormElements(org.w3c.dom.Document)
.
public static Document translateFormElements(Document origDoc)
Translates form elements to ordinary div
's so one doesn't
see the form elements on printout. Currently only converts input
and button
. For example
will be replaced with
<input type="text" name="foo" value="form element value" />
<span class="replaced-form-element">form element value</span>
On success, a new document with replaced elements is returned. If an error occurs, the unmodified document is returned.
Copyright © 2010-2018 Nikhef / Stichting FOM. All Rights Reserved.