com.ibm.as400.util.reportwriter.pdfwriter
Class PDFContext

com.ibm.as400.util.reportwriter.pdfwriter.PDFContext

public class PDFContext

The PDFContext class defines the methods necessary to render an area tree to a PDF data stream according to the rendering model of the XSL FO specification. An application is only required to create an instance of the PDFContext. The public methods defined in PDFContext are called internally.


Constructor Summary
PDFContext(java.io.OutputStream out, java.awt.print.PageFormat pF)
          Constructs a PDFContext object.
 
Method Summary
 void drawBorder(com.ibm.xsl.composer.prim.Border inTop, com.ibm.xsl.composer.prim.Border inLeft, com.ibm.xsl.composer.prim.Border inBottom, com.ibm.xsl.composer.prim.Border inRight, com.ibm.as400.util.reportwriter.pdfwriter.CSSPoint inLocation, com.ibm.as400.util.reportwriter.pdfwriter.CSSExtent inSize)
          Draw the border using the border traits given.
 void drawGlyph(char code, com.ibm.as400.util.reportwriter.pdfwriter.CSSPoint location)
          Draw a single glyph at the given location.
 void drawGraphic(java.lang.String Uri, com.ibm.as400.util.reportwriter.pdfwriter.CSSPoint location, com.ibm.as400.util.reportwriter.pdfwriter.CSSExtent size)
          Draw an image resource at the given location.
 void drawOrientatedGlyph(char code, com.ibm.as400.util.reportwriter.pdfwriter.CSSPoint location, short referenceOrientation)
          Draw a single glyph at the given location with the specified orientation.
 void drawRule(com.ibm.as400.util.reportwriter.pdfwriter.CSSPoint start, com.ibm.as400.util.reportwriter.pdfwriter.CSSPoint end, com.ibm.xsl.composer.prim.Border border)
          Draw a rule from the start point to the end point with given border properties.
 void drawString(java.lang.String series, com.ibm.as400.util.reportwriter.pdfwriter.CSSPoint location)
          Draw a series of glyphs at the given location.
 void endDocument()
          Called at the end of processing a document, after all other output methods.
 void fillBackground(com.ibm.as400.util.reportwriter.pdfwriter.CSSPoint location, com.ibm.as400.util.reportwriter.pdfwriter.CSSExtent size, com.ibm.as400.util.reportwriter.pdfwriter.CSSColor color)
          Fill a rectangle with color.
 void fillBackground(com.ibm.as400.util.reportwriter.pdfwriter.CSSPoint location, com.ibm.as400.util.reportwriter.pdfwriter.CSSExtent size, java.lang.String imageName, com.ibm.as400.util.reportwriter.pdfwriter.CSSPoint offset, int howToRepeat)
          Fill a rectangle with an image.
 com.ibm.as400.util.reportwriter.pdfwriter.ExtendedFont getExtendedFont(com.ibm.xsl.composer.properties.FontProperty fontProperty)
          Get the class which reports metrics for a font that most nearly satisfies the given properties.
 com.ibm.as400.util.reportwriter.pdfwriter.CSSExtent getGraphicDimension(java.lang.String image)
          Retrieve the dimensions of an image resource.
 com.ibm.as400.util.reportwriter.pdfwriter.CSSExtent getPageSize()
          Get the size of the output media in fo space (long units).
 long getUnitsPerPixel()
          Get number of units in fo space equal to one pixel in device space.
 long getUnitsPerPoint()
          Get number of units in fo space equal to one point in device space.
 void notifyGraphic(java.net.URL image)
          Indicate to the context that an image resource may be used in a later call to fillBackground or drawGraphic.
 void setFont(com.ibm.as400.util.reportwriter.pdfwriter.ExtendedFont extendedFont)
          Set the font for rendering text to a font that most nearly satisfies the given properties.
 void setTextColor(com.ibm.as400.util.reportwriter.pdfwriter.CSSColor color)
          Set the color for rendering text and rules.
 void startDocument()
          Called at the start of processing a document, before any other output methods.
 void startViewport(com.ibm.as400.util.reportwriter.pdfwriter.CSSPoint location, com.ibm.as400.util.reportwriter.pdfwriter.CSSExtent extent, boolean isPage)
          Start a viewport with the given location and extent.
 

Constructor Detail

PDFContext

public PDFContext(java.io.OutputStream out,
                  java.awt.print.PageFormat pF)
           throws java.lang.NullPointerException
Constructs a PDFContext object.
Parameters:
out - The OutputStream used to hold the PDF data.
pF - The PageFormat describes the size and orientation of a page to be printed.
Throws:
java.lang.NullPointerException - If the OutputStream or PageFormat is null.
Method Detail

getPageSize

public com.ibm.as400.util.reportwriter.pdfwriter.CSSExtent getPageSize()
Get the size of the output media in fo space (long units).
Returns:
extent of the device, by copy.

getUnitsPerPoint

public long getUnitsPerPoint()
Get number of units in fo space equal to one point in device space.
Returns:
number of units per point

getUnitsPerPixel

public long getUnitsPerPixel()
Get number of units in fo space equal to one pixel in device space.
Returns:
number of units per pixel

startDocument

public void startDocument()
Called at the start of processing a document, before any other output methods. Allows the implementation to do initialialization.

endDocument

public void endDocument()
Called at the end of processing a document, after all other output methods. Allows the implementation to do end processing, such as ejecting the final page.

startViewport

public void startViewport(com.ibm.as400.util.reportwriter.pdfwriter.CSSPoint location,
                          com.ibm.as400.util.reportwriter.pdfwriter.CSSExtent extent,
                          boolean isPage)
Start a viewport with the given location and extent.
Parameters:
location - the location of the start of the viewport.
extent - the extent of the vieport.
isPage - if true, on a page device, open the viewport on a new page; on a screen device, open a new window.

getExtendedFont

public com.ibm.as400.util.reportwriter.pdfwriter.ExtendedFont getExtendedFont(com.ibm.xsl.composer.properties.FontProperty fontProperty)
Get the class which reports metrics for a font that most nearly satisfies the given properties.
Parameters:
fontProperty - an XSL font property object
Returns:
ExtendedFont A font metrics class, which is immutable.

setFont

public void setFont(com.ibm.as400.util.reportwriter.pdfwriter.ExtendedFont extendedFont)
Set the font for rendering text to a font that most nearly satisfies the given properties.
Parameters:
extendedFont - the font information from the framework
See Also:
#getExtendedFont()

setTextColor

public void setTextColor(com.ibm.as400.util.reportwriter.pdfwriter.CSSColor color)
Set the color for rendering text and rules.
Parameters:
color - text color

drawGlyph

public void drawGlyph(char code,
                      com.ibm.as400.util.reportwriter.pdfwriter.CSSPoint location)
Draw a single glyph at the given location. Draws with the font last set, in the color last set.
Parameters:
code - the codepoint
location - the location of the start of the glyph at it's baseline.
See Also:
setFont(com.ibm.as400.util.reportwriter.pdfwriter.ExtendedFont), setTextColor(com.ibm.as400.util.reportwriter.pdfwriter.CSSColor)

drawOrientatedGlyph

public void drawOrientatedGlyph(char code,
                                com.ibm.as400.util.reportwriter.pdfwriter.CSSPoint location,
                                short referenceOrientation)
Draw a single glyph at the given location with the specified orientation. Draws with the font last set, in the color last set.
Parameters:
code - the codepoint
location - the location of the start of the glyph at it's baseline.
referenceOrientation - the orientation of the glyph
See Also:
setFont(com.ibm.as400.util.reportwriter.pdfwriter.ExtendedFont), setTextColor(com.ibm.as400.util.reportwriter.pdfwriter.CSSColor)

drawString

public void drawString(java.lang.String series,
                       com.ibm.as400.util.reportwriter.pdfwriter.CSSPoint location)
Draw a series of glyphs at the given location. Draws with the font last set, in the color last set.
Parameters:
series - the sequence of codepoints
location - the location of the start of the first glyph at it's baseline.
See Also:
setFont(com.ibm.as400.util.reportwriter.pdfwriter.ExtendedFont), setTextColor(com.ibm.as400.util.reportwriter.pdfwriter.CSSColor)

drawRule

public void drawRule(com.ibm.as400.util.reportwriter.pdfwriter.CSSPoint start,
                     com.ibm.as400.util.reportwriter.pdfwriter.CSSPoint end,
                     com.ibm.xsl.composer.prim.Border border)
Draw a rule from the start point to the end point with given border properties.
Parameters:
start - the first endpoint.
end - the second endpoint.
border - the properties of the border

drawBorder

public void drawBorder(com.ibm.xsl.composer.prim.Border inTop,
                       com.ibm.xsl.composer.prim.Border inLeft,
                       com.ibm.xsl.composer.prim.Border inBottom,
                       com.ibm.xsl.composer.prim.Border inRight,
                       com.ibm.as400.util.reportwriter.pdfwriter.CSSPoint inLocation,
                       com.ibm.as400.util.reportwriter.pdfwriter.CSSExtent inSize)
Draw the border using the border traits given.
Parameters:
inTop - properties of the top border
inLeft - properties of the left border
inBottom - properties of the bottom border
inRight - properties of the right border
inLocation - of the rectangle internal to the border
inSize - of the rectangle internal to the border

fillBackground

public void fillBackground(com.ibm.as400.util.reportwriter.pdfwriter.CSSPoint location,
                           com.ibm.as400.util.reportwriter.pdfwriter.CSSExtent size,
                           com.ibm.as400.util.reportwriter.pdfwriter.CSSColor color)
Fill a rectangle with color.
Parameters:
location - of the rectangle.
size - of the rectangle
color - to fill

fillBackground

public void fillBackground(com.ibm.as400.util.reportwriter.pdfwriter.CSSPoint location,
                           com.ibm.as400.util.reportwriter.pdfwriter.CSSExtent size,
                           java.lang.String imageName,
                           com.ibm.as400.util.reportwriter.pdfwriter.CSSPoint offset,
                           int howToRepeat)
Fill a rectangle with an image.
Parameters:
location - of the rectangle.
size - of the rectangle
imageName - uri for the image
offset - the offset of the origin of the image
howToRepeat - whether and how to tile the image

notifyGraphic

public void notifyGraphic(java.net.URL image)
Indicate to the context that an image resource may be used in a later call to fillBackground or drawGraphic.
Parameters:
image - the uri for the image

drawGraphic

public void drawGraphic(java.lang.String Uri,
                        com.ibm.as400.util.reportwriter.pdfwriter.CSSPoint location,
                        com.ibm.as400.util.reportwriter.pdfwriter.CSSExtent size)
Draw an image resource at the given location.
Parameters:
Uri - the uri for the image
location - the location of the start of the glyph at it's baseline.
size - of the image (context must scale to this size)

getGraphicDimension

public com.ibm.as400.util.reportwriter.pdfwriter.CSSExtent getGraphicDimension(java.lang.String image)
Retrieve the dimensions of an image resource.
Parameters:
image - the uri for the image
Returns:
size of the image