com.qoppa.pdf.dom
Interface IPDFPage


public interface IPDFPage

Object representation of a page in a PDF document. This interface provides information about a page in a PDF document and has methods to paint and print the page.

Author:
Qoppa Software

Method Summary
 TextSelection clearTextSelection()
          Clear any text selection on the page.
 Vector getAnnotations()
          Returns a list of PDF annotations in this page.
 Rectangle2D getBleedBox()
          Return this page's Bleed Box.
 Rectangle2D getCropBox()
          Return this page's Crop Box.
 double getDisplayHeight()
          Gets the page's display height.
 double getDisplayWidth()
          Gets the page's display width.
 double getDisplayX()
          Returns the page's left margin.
 double getDisplayY()
          Returns the page's top margin.
 BufferedImage getImage(int width, int height, boolean keepAspect)
          Returns a buffered image showing the contents of this page.
 Rectangle2D getMediaBox()
          Returns this page's Media Box.
 int getPageRotation()
          Returns the rotation of this page in degrees.
 TextSelection getSelectedText()
          Returns information about currently selected text on the page.
 BufferedImage getSubImage(Rectangle2D pageArea, double scale)
          Create a BufferedImage of a sub rectangle in a page at a given scale.
 Vector getText(int pageIndex)
          Return a list of PDFText objects containing all the text in this page.
 Rectangle2D getTrimBox()
          Return this page's Trim Box.
 void paintPage(Graphics2D g2d)
          Paints this page to the given graphics object.
 void printPage(Graphics2D g2d, PageFormat pf, PrintSettings printSettings)
          Prints this page given a page format describing the printer's page and a PrintSettings object.
 TextSelection selectText(Rectangle2D selectArea)
          Selects the text in an area of the page.
 void setInvertMode(boolean invertMode)
          Sets the page to paint in inverted mode: Black will show as white and white as black.
 

Method Detail

getMediaBox

public Rectangle2D getMediaBox()
Returns this page's Media Box. The media box is equivalent to the physical paper the page was designed for.

Returns:
The page's media box.

getCropBox

public Rectangle2D getCropBox()
Return this page's Crop Box. The crop box in a page determines what area of the page will be displayed or printed.

Returns:
The page's crop box.

getBleedBox

public Rectangle2D getBleedBox()
Return this page's Bleed Box. A page should be clipped to this coordinates when output to a production environment. jPDFViewer does not use the Bleed Box, it uses the Crop Box to clip a page before displaying. The method is provided for information to the host application.

Returns:
The page's bleed box.

getTrimBox

public Rectangle2D getTrimBox()
Return this page's Trim Box. The trim box defines a finished page's intended dimension after trimming. jPDFViewer does not use the Trim Box, the method is provided here for information to the host application.

Returns:
The page's crop box.

paintPage

public void paintPage(Graphics2D g2d)
Paints this page to the given graphics object.

Parameters:
g2d - Graphics objects to paint the page to.
Throws:
PDFException - Any errors encountered during painting the page.

setInvertMode

public void setInvertMode(boolean invertMode)
Sets the page to paint in inverted mode: Black will show as white and white as black. Colors will be inverted as well by XOR'ing them with all white.

Parameters:
invertMode - The new invert mode.

printPage

public void printPage(Graphics2D g2d,
                      PageFormat pf,
                      PrintSettings printSettings)
Prints this page given a page format describing the printer's page and a PrintSettings object.

Parameters:
g2d - Printer graphics object.
pf - PageFormat object to use when printing.
printSettings - Printing preferences.

getDisplayHeight

public double getDisplayHeight()
Gets the page's display height. This is equivalent to getCropBox().getHeight();

Returns:
The page's display height.

getDisplayWidth

public double getDisplayWidth()
Gets the page's display width. This is equivalent to getCropBox().getWidth();

Returns:
The page's display width.

getDisplayX

public double getDisplayX()
Returns the page's left margin. This value correspond to the different between the page's CropBox X coordinate and the MediaBox X coordinate. When the page is, this will be the origin of the displayed page.

Returns:
The page's display X coordinate.

getDisplayY

public double getDisplayY()
Returns the page's top margin. This value correspond to the different between the page's CropBox Y coordinate and the MediaBox Y coordinate. When the page is, this will be the origin of the displayed page.

Returns:
The page's display Y coordinate.

getPageRotation

public int getPageRotation()
Returns the rotation of this page in degrees.

Returns:
int Page rotation in degrees.

getAnnotations

public Vector getAnnotations()
                      throws PDFException
Returns a list of PDF annotations in this page. The objects in the Vector are all derived from com.qoppa.pdf.annotations.Annotation.

Returns:
List of annotations.
Throws:
PDFException

getText

public Vector getText(int pageIndex)
               throws PDFException
Return a list of PDFText objects containing all the text in this page.

Returns:
List of PDFText objects.
Throws:
PDFException

selectText

public TextSelection selectText(Rectangle2D selectArea)
                         throws PDFException
Selects the text in an area of the page. The coordinates on the page should be in 'display' coords, i.e. the origin of the coordinates is page.getCropBox.getX() and page.getCropBox().getY();

Returns:
A TextSelection object representing the selected text. null if no text is selected.
Throws:
PDFException

clearTextSelection

public TextSelection clearTextSelection()
                                 throws PDFException
Clear any text selection on the page.

Returns:
The current text selection (before clearing it).
Throws:
PDFException

getSelectedText

public TextSelection getSelectedText()
Returns information about currently selected text on the page.

Returns:
The current text selection.

getImage

public BufferedImage getImage(int width,
                              int height,
                              boolean keepAspect)
Returns a buffered image showing the contents of this page. The image is resized to the given width and height. If keepAspect is true, the resized image keeps its aspect ratio.

Parameters:
width - Width of the desired image.
height - Height of the desired image.
keepAspect - Flag to indicate whether the resized image should keep its aspect ratio.
Returns:
BufferedImage with the contents of the page.

getSubImage

public BufferedImage getSubImage(Rectangle2D pageArea,
                                 double scale)
Create a BufferedImage of a sub rectangle in a page at a given scale.

Parameters:
pageArea - The rectangle of interest in the page. This rectangle should be in PDF native resolution, 72 DPI.
scale - The scale at which to render the image. Scale = 1.0 means no scaling.
Returns:
An image of the rectangle of a page.