public class PrintTranscoder extends SVGAbstractTranscoder implements Printable
Transcoder that prints SVG images.
This class works as follows: any-time the transcode method
is invoked, the corresponding input is cached and nothing
else happens. PrintTranscoder is also a Printable. If used
in a print operation, it will print each of the input
it cached, one input per page.
PrintTranscoder uses several different hints that
guide its printing:KEY_LANGUAGE, KEY_USER_STYLESHEET_URI, KEY_PIXEL_TO_MM,
KEY_XML_PARSER_CLASSNAME can be used to set the defaults for
the various SVG properties.KEY_PAGE_WIDTH, KEY_PAGE_HEIGHT, KEY_MARGIN_TOP, KEY_MARGIN_BOTTOM,
KEY_MARGIN_LEFT, KEY_MARGIN_RIGHT and KEY_PAGE_ORIENTATION
can be used to specify the printing page characteristics.KEY_WIDTH, KEY_HEIGHT can be used to specify how to scale the
SVG imageKEY_SCALE_TO_PAGE can be used to specify whether or not the
SVG image should be scaled uniformly to fit into the printed page or
if it should just be centered into the printed page.SVGAbstractTranscoder.SVGAbstractTranscoderUserAgentbuilder, ctx, curAOI, curTxf, DEFAULT_ALLOWED_SCRIPT_TYPES, DEFAULT_DEFAULT_FONT_FAMILY, height, KEY_ALLOW_EXTERNAL_RESOURCES, KEY_ALLOWED_SCRIPT_TYPES, KEY_ALTERNATE_STYLESHEET, KEY_AOI, KEY_CONSTRAIN_SCRIPT_ORIGIN, KEY_DEFAULT_FONT_FAMILY, KEY_EXECUTE_ONLOAD, KEY_HEIGHT, KEY_LANGUAGE, KEY_MAX_HEIGHT, KEY_MAX_WIDTH, KEY_MEDIA, KEY_PIXEL_TO_MM, KEY_PIXEL_UNIT_TO_MILLIMETER, KEY_SNAPSHOT_TIME, KEY_USER_STYLESHEET_URI, KEY_WIDTH, root, userAgent, widthKEY_DOCUMENT_ELEMENT, KEY_DOCUMENT_ELEMENT_NAMESPACE_URI, KEY_DOM_IMPLEMENTATION, KEY_XML_PARSER_CLASSNAME, KEY_XML_PARSER_VALIDATINGhandler, hintsNO_SUCH_PAGE, PAGE_EXISTS| Constructor and Description |
|---|
PrintTranscoder()
Constructs a new transcoder that prints images.
|
| Modifier and Type | Method and Description |
|---|---|
static void |
handleValueError(String property,
String value) |
static void |
main(String[] args) |
void |
print()
Convenience method
|
int |
print(Graphics _g,
PageFormat pageFormat,
int pageIndex)
Printable implementation
|
protected void |
setImageSize(float docWidth,
float docHeight)
Sets document size according to the hints.
|
static void |
setTranscoderBooleanHint(Transcoder transcoder,
String property,
TranscodingHints.Key key) |
static void |
setTranscoderFloatHint(Transcoder transcoder,
String property,
TranscodingHints.Key key) |
static void |
setTranscoderRectangleHint(Transcoder transcoder,
String property,
TranscodingHints.Key key) |
static void |
setTranscoderStringHint(Transcoder transcoder,
String property,
TranscodingHints.Key key) |
protected void |
transcode(Document document,
String uri,
TranscoderOutput output)
Transcodes the specified Document as an image in the specified output.
|
void |
transcode(TranscoderInput in,
TranscoderOutput out)
Transcodes the specified XML input in the specified output.
|
createBridgeContext, createBridgeContext, createBridgeContext, createDocumentFactory, createUserAgent, getCanvasGraphicsNodeaddTranscodingHint, getErrorHandler, getTranscodingHints, removeTranscodingHint, setErrorHandler, setTranscodingHints, setTranscodingHintsclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddTranscodingHint, getErrorHandler, getTranscodingHints, removeTranscodingHint, setErrorHandler, setTranscodingHints, setTranscodingHintspublic static final String KEY_AOI_STR
public static final String KEY_HEIGHT_STR
public static final String KEY_LANGUAGE_STR
public static final String KEY_MARGIN_BOTTOM_STR
public static final String KEY_MARGIN_LEFT_STR
public static final String KEY_MARGIN_RIGHT_STR
public static final String KEY_MARGIN_TOP_STR
public static final String KEY_PAGE_HEIGHT_STR
public static final String KEY_PAGE_ORIENTATION_STR
public static final String KEY_PAGE_WIDTH_STR
public static final String KEY_PIXEL_TO_MM_STR
public static final String KEY_SCALE_TO_PAGE_STR
public static final String KEY_SHOW_PAGE_DIALOG_STR
public static final String KEY_SHOW_PRINTER_DIALOG_STR
public static final String KEY_USER_STYLESHEET_URI_STR
public static final String KEY_WIDTH_STR
public static final String KEY_XML_PARSER_CLASSNAME_STR
public static final String VALUE_MEDIA_PRINT
public static final String VALUE_PAGE_ORIENTATION_LANDSCAPE
public static final String VALUE_PAGE_ORIENTATION_PORTRAIT
public static final String VALUE_PAGE_ORIENTATION_REVERSE_LANDSCAPE
public static final TranscodingHints.Key KEY_SHOW_PAGE_DIALOG
| Key: | KEY_SHOW_PAGE_DIALOG |
|---|---|
| Value: | Boolean |
| Default: | false |
| Required: | No |
| Description: | Specifies whether or not the transcoder should pop up a dialog box for selecting the page format. |
public static final TranscodingHints.Key KEY_SHOW_PRINTER_DIALOG
| Key: | KEY_SHOW_PAGE_DIALOG |
|---|---|
| Value: | Boolean |
| Default: | false |
| Required: | No |
| Description: | Specifies whether or not the transcoder should pop up a dialog box for selecting the printer. If the dialog box is not shown, the transcoder will use the default printer. |
public static final TranscodingHints.Key KEY_PAGE_WIDTH
| Key: | KEY_PAGE_WIDTH |
|---|---|
| Value: | Length |
| Default: | None |
| Required: | No |
| Description: | The width of the print page |
public static final TranscodingHints.Key KEY_PAGE_HEIGHT
| Key: | KEY_PAGE_HEIGHT |
|---|---|
| Value: | Length |
| Default: | none |
| Required: | No |
| Description: | The height of the print page |
public static final TranscodingHints.Key KEY_MARGIN_TOP
| Key: | KEY_MARGIN_TOP |
|---|---|
| Value: | Length |
| Default: | None |
| Required: | No |
| Description: | The print page top margin |
public static final TranscodingHints.Key KEY_MARGIN_RIGHT
| Key: | KEY_MARGIN_RIGHT |
|---|---|
| Value: | Length |
| Default: | None |
| Required: | No |
| Description: | The print page right margin |
public static final TranscodingHints.Key KEY_MARGIN_BOTTOM
| Key: | KEY_MARGIN_BOTTOM |
|---|---|
| Value: | Length |
| Default: | None |
| Required: | No |
| Description: | The print page bottom margin |
public static final TranscodingHints.Key KEY_MARGIN_LEFT
| Key: | KEY_MARGIN_LEFT |
|---|---|
| Value: | Length |
| Default: | None |
| Required: | No |
| Description: | The print page left margin |
public static final TranscodingHints.Key KEY_PAGE_ORIENTATION
| Key: | KEY_PAGE_ORIENTATION |
|---|---|
| Value: | String |
| Default: | VALUE_PAGE_ORIENTATION_PORTRAIT |
| Required: | No |
| Description: | The print page's orientation |
public static final TranscodingHints.Key KEY_SCALE_TO_PAGE
| Key: | KEY_SCALE_TO_PAGE |
|---|---|
| Value: | Boolean |
| Default: | true |
| Required: | No |
| Description: | Specifies whether or not the SVG images are scaled to fit into the printed page |
public static final String USAGE
public PrintTranscoder()
public void transcode(TranscoderInput in, TranscoderOutput out)
XMLAbstractTranscoderTranscoderException exceptions not catched previously
are tagged as fatal errors (ie. call the fatalError
method of the ErrorHandler).transcode in interface Transcodertranscode in class SVGAbstractTranscoderin - the XML input to transcodeout - the ouput where to transcodeprotected void transcode(Document document, String uri, TranscoderOutput output) throws TranscoderException
transcode in class SVGAbstractTranscoderdocument - the document to transcodeuri - the uri of the document or null if anyoutput - the ouput where to transcodeTranscoderException - if an error occured while transcodingpublic void print()
throws PrinterException
PrinterExceptionpublic int print(Graphics _g, PageFormat pageFormat, int pageIndex)
protected void setImageSize(float docWidth,
float docHeight)
setImageSize in class SVGAbstractTranscoderdocWidth - Width of the document.docHeight - Height of the document.public static void setTranscoderFloatHint(Transcoder transcoder, String property, TranscodingHints.Key key)
public static void setTranscoderRectangleHint(Transcoder transcoder, String property, TranscodingHints.Key key)
public static void setTranscoderBooleanHint(Transcoder transcoder, String property, TranscodingHints.Key key)
public static void setTranscoderStringHint(Transcoder transcoder, String property, TranscodingHints.Key key)
Copyright © 2000–2024 Apache Software Foundation. All rights reserved.