org.apache.batik.transcoder.print

Class PrintTranscoder

public class PrintTranscoder extends SVGAbstractTranscoder implements Printable

This class is a 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.
However, the PrintTranscoder is also a Printable. If used in a print operation, it will print each of the input it cached, one input per page.
The PrintTranscoder uses several different hints that guide its printing:
Field Summary
static StringKEY_AOI_STR
static StringKEY_HEIGHT_STR
static StringKEY_LANGUAGE_STR
static TranscodingHints.KeyKEY_MARGIN_BOTTOM
The marginBottom key.
static StringKEY_MARGIN_BOTTOM_STR
static TranscodingHints.KeyKEY_MARGIN_LEFT
The marginLeft key.
static StringKEY_MARGIN_LEFT_STR
static TranscodingHints.KeyKEY_MARGIN_RIGHT
The marginRight key.
static StringKEY_MARGIN_RIGHT_STR
static TranscodingHints.KeyKEY_MARGIN_TOP
The marginTop key.
static StringKEY_MARGIN_TOP_STR
static TranscodingHints.KeyKEY_PAGE_HEIGHT
The pageHeight key.
static StringKEY_PAGE_HEIGHT_STR
static TranscodingHints.KeyKEY_PAGE_ORIENTATION
The pageOrientation key.
static StringKEY_PAGE_ORIENTATION_STR
static TranscodingHints.KeyKEY_PAGE_WIDTH
The pageWidth key.
static StringKEY_PAGE_WIDTH_STR
static StringKEY_PIXEL_TO_MM_STR
static TranscodingHints.KeyKEY_SCALE_TO_PAGE
The scaleToPage key.
static StringKEY_SCALE_TO_PAGE_STR
static TranscodingHints.KeyKEY_SHOW_PAGE_DIALOG
The showPageDialog key.
static StringKEY_SHOW_PAGE_DIALOG_STR
static TranscodingHints.KeyKEY_SHOW_PRINTER_DIALOG
The showPrinterDialog key.
static StringKEY_SHOW_PRINTER_DIALOG_STR
static StringKEY_USER_STYLESHEET_URI_STR
static StringKEY_WIDTH_STR
static StringKEY_XML_PARSER_CLASSNAME_STR
static StringUSAGE
static StringVALUE_MEDIA_PRINT
static StringVALUE_PAGE_ORIENTATION_LANDSCAPE
static StringVALUE_PAGE_ORIENTATION_PORTRAIT
static StringVALUE_PAGE_ORIENTATION_REVERSE_LANDSCAPE
Constructor Summary
PrintTranscoder()
Constructs a new transcoder that prints images.
Method Summary
static voidhandleValueError(String property, String value)
static voidmain(String[] args)
voidprint()
Convenience method
intprint(Graphics _g, PageFormat pageFormat, int pageIndex)
Printable implementation
protected voidsetImageSize(float docWidth, float docHeight)
Sets document size according to the hints.
static voidsetTranscoderBooleanHint(Transcoder transcoder, String property, TranscodingHints.Key key)
static voidsetTranscoderFloatHint(Transcoder transcoder, String property, TranscodingHints.Key key)
static voidsetTranscoderRectangleHint(Transcoder transcoder, String property, TranscodingHints.Key key)
static voidsetTranscoderStringHint(Transcoder transcoder, String property, TranscodingHints.Key key)
voidtranscode(TranscoderInput in, TranscoderOutput out)
protected voidtranscode(Document document, String uri, TranscoderOutput output)
Transcodes the specified Document as an image in the specified output.

Field Detail

KEY_AOI_STR

public static final String KEY_AOI_STR

KEY_HEIGHT_STR

public static final String KEY_HEIGHT_STR

KEY_LANGUAGE_STR

public static final String KEY_LANGUAGE_STR

KEY_MARGIN_BOTTOM

public static final TranscodingHints.Key KEY_MARGIN_BOTTOM
The marginBottom key.

Key:

KEY_MARGIN_BOTTOM

Value:

Length

Default:

None

Required:

No

Description:

The print page bottom margin

KEY_MARGIN_BOTTOM_STR

public static final String KEY_MARGIN_BOTTOM_STR

KEY_MARGIN_LEFT

public static final TranscodingHints.Key KEY_MARGIN_LEFT
The marginLeft key.

Key:

KEY_MARGIN_LEFT

Value:

Length

Default:

None

Required:

No

Description:

The print page left margin

KEY_MARGIN_LEFT_STR

public static final String KEY_MARGIN_LEFT_STR

KEY_MARGIN_RIGHT

public static final TranscodingHints.Key KEY_MARGIN_RIGHT
The marginRight key.

Key:

KEY_MARGIN_RIGHT

Value:

Length

Default:

None

Required:

No

Description:

The print page right margin

KEY_MARGIN_RIGHT_STR

public static final String KEY_MARGIN_RIGHT_STR

KEY_MARGIN_TOP

public static final TranscodingHints.Key KEY_MARGIN_TOP
The marginTop key.

Key:

KEY_MARGIN_TOP

Value:

Length

Default:

None

Required:

No

Description:

The print page top margin

KEY_MARGIN_TOP_STR

public static final String KEY_MARGIN_TOP_STR

KEY_PAGE_HEIGHT

public static final TranscodingHints.Key KEY_PAGE_HEIGHT
The pageHeight key.

Key:

KEY_PAGE_HEIGHT

Value:

Length

Default:

None

Required:

No

Description:

The height of the print page

KEY_PAGE_HEIGHT_STR

public static final String KEY_PAGE_HEIGHT_STR

KEY_PAGE_ORIENTATION

public static final TranscodingHints.Key KEY_PAGE_ORIENTATION
The pageOrientation key.

Key:

KEY_PAGE_ORIENTATION

Value:

String

Default:

VALUE_PAGE_ORIENTATION_PORTRAIT

Required:

No

Description:

The print page's orientation

KEY_PAGE_ORIENTATION_STR

public static final String KEY_PAGE_ORIENTATION_STR

KEY_PAGE_WIDTH

public static final TranscodingHints.Key KEY_PAGE_WIDTH
The pageWidth key.

Key:

KEY_PAGE_WIDTH

Value:

Length

Default:

None

Required:

No

Description:

The width of the print page

KEY_PAGE_WIDTH_STR

public static final String KEY_PAGE_WIDTH_STR

KEY_PIXEL_TO_MM_STR

public static final String KEY_PIXEL_TO_MM_STR

KEY_SCALE_TO_PAGE

public static final TranscodingHints.Key KEY_SCALE_TO_PAGE
The scaleToPage key.

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

KEY_SCALE_TO_PAGE_STR

public static final String KEY_SCALE_TO_PAGE_STR

KEY_SHOW_PAGE_DIALOG

public static final TranscodingHints.Key KEY_SHOW_PAGE_DIALOG
The showPageDialog key.

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.

KEY_SHOW_PAGE_DIALOG_STR

public static final String KEY_SHOW_PAGE_DIALOG_STR

KEY_SHOW_PRINTER_DIALOG

public static final TranscodingHints.Key KEY_SHOW_PRINTER_DIALOG
The showPrinterDialog key.

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.

KEY_SHOW_PRINTER_DIALOG_STR

public static final String KEY_SHOW_PRINTER_DIALOG_STR

KEY_USER_STYLESHEET_URI_STR

public static final String KEY_USER_STYLESHEET_URI_STR

KEY_WIDTH_STR

public static final String KEY_WIDTH_STR

KEY_XML_PARSER_CLASSNAME_STR

public static final String KEY_XML_PARSER_CLASSNAME_STR

USAGE

public static final String USAGE

VALUE_MEDIA_PRINT

public static final String VALUE_MEDIA_PRINT

VALUE_PAGE_ORIENTATION_LANDSCAPE

public static final String VALUE_PAGE_ORIENTATION_LANDSCAPE

VALUE_PAGE_ORIENTATION_PORTRAIT

public static final String VALUE_PAGE_ORIENTATION_PORTRAIT

VALUE_PAGE_ORIENTATION_REVERSE_LANDSCAPE

public static final String VALUE_PAGE_ORIENTATION_REVERSE_LANDSCAPE

Constructor Detail

PrintTranscoder

public PrintTranscoder()
Constructs a new transcoder that prints images.

Method Detail

handleValueError

public static void handleValueError(String property, String value)

main

public static void main(String[] args)

print

public void print()
Convenience method

print

public int print(Graphics _g, PageFormat pageFormat, int pageIndex)
Printable implementation

setImageSize

protected void setImageSize(float docWidth, float docHeight)
Sets document size according to the hints. Global variables width and height are modified.

Parameters: docWidth Width of the document. docHeight Height of the document.

setTranscoderBooleanHint

public static void setTranscoderBooleanHint(Transcoder transcoder, String property, TranscodingHints.Key key)

setTranscoderFloatHint

public static void setTranscoderFloatHint(Transcoder transcoder, String property, TranscodingHints.Key key)

setTranscoderRectangleHint

public static void setTranscoderRectangleHint(Transcoder transcoder, String property, TranscodingHints.Key key)

setTranscoderStringHint

public static void setTranscoderStringHint(Transcoder transcoder, String property, TranscodingHints.Key key)

transcode

public void transcode(TranscoderInput in, TranscoderOutput out)

transcode

protected void transcode(Document document, String uri, TranscoderOutput output)
Transcodes the specified Document as an image in the specified output.

Parameters: document the document to transcode uri the uri of the document or null if any output the ouput where to transcode

Throws: TranscoderException if an error occured while transcoding

Copyright B) 2007 Apache Software Foundation. All Rights Reserved.