com.qoppa.pdf.dom
Interface IPDFPage

All Known Implementing Classes:
com.qoppa.pdfViewer.hiObjects.AbstractPDFPage, PDFPage

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
 Vector findText(String searchText, boolean caseSensitive, boolean wholeWords)
          This method searches for the given text in the page.
 Vector findTextWithContext(String searchText, boolean caseSensitive, boolean wholeWords)
          This method searches for the given text in the page.
 Vector getAnnotations()
          Returns a list of PDF annotations in this page.
 Rectangle2D getArtBox()
          Return this page's Art Box.
 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.
 IPDFDocument getIDocument()
          Returns the document that this page belongs to.
 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 getPageIndex()
          This method returns the index of this page in its parent document.
 int getPageRotation()
          Returns the rotation of this page in degrees.
 String getTabbingOrder()
          Returns the tabbing order as defined in the page description, if present.
 String getText()
          Returns the text content of this page as a String.
 TextSelection getTextInArea(Rectangle2D selectArea)
          Selects the text in an area of the page.
 TextSelection getTextSelection(Rectangle2D selectRect)
          Deprecated. Use getTextInArea instead
 TextSelection getTextWithCursors(Point2D startCursor, Point2D endCursor)
          Returns the text contained between the start and end cursors, in "reading mode".
 Rectangle2D getTrimBox()
          Return this page's Trim Box.
 void paintPage(Graphics2D g2d)
          Paints this page to the given graphics object.
 void paintPage(Graphics2D g2d, boolean paintAnnotations)
          Paints this page to the given graphics object, with an option to paint the annotations on the page.
 void printPage(Graphics2D g2d, PageFormat pf, PrintSettings printSettings)
          Prints this page given a page format describing the printer's page and a PrintSettings object.
 

Method Detail

getMediaBox

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

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

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

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.

getArtBox

Rectangle2D getArtBox()
Return this page's Art Box. The art box defines the extent of the page's meaningful content (including potential whitespace). jPDFViewer does not use the Art Box, the method is provided here for information to the host application.

Returns:
The page's art box.

paintPage

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.

paintPage

void paintPage(Graphics2D g2d,
               boolean paintAnnotations)
Paints this page to the given graphics object, with an option to paint the annotations on the page.

Parameters:
g2d - Graphics objects to paint the page to.
paintAnnotations - Flag indicating whether annotations should be painted
Throws:
PDFException - Any errors encountered during painting the page.

printPage

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

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

Returns:
The page's display height.

getDisplayWidth

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

Returns:
The page's display width.

getDisplayX

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

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

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

Returns:
int Page rotation in degrees.

getPageIndex

int getPageIndex()
This method returns the index of this page in its parent document.

Returns:
the index of the page

getAnnotations

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

getImage

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.

findTextWithContext

Vector findTextWithContext(String searchText,
                           boolean caseSensitive,
                           boolean wholeWords)
                           throws PDFException
This method searches for the given text in the page. If there are instances of the text found, the method returns a Vector of TextPositionWithContext objects. These objects contain information about the text, its position and the surrounding text.

Parameters:
searchText - The text to search for.
caseSensitive - Flag to determine if the search should be case sensitive.
wholeWords - Flag to indicate if only whole words should be found
Returns:
A list of TextPositionWithContext objects
Throws:
PDFException

findText

Vector findText(String searchText,
                boolean caseSensitive,
                boolean wholeWords)
                throws PDFException
This method searches for the given text in the page. If there are instances of the text found, the method returns a Vector of TextPosition objects. These objects contain information about the text and its position.

Parameters:
searchText - The text to search for.
caseSensitive - Flag to determine if the search should be case sensitive.
wholeWords - Flag to indicate if only whole words should be found
Returns:
A list of TextPosition objects
Throws:
PDFException

getTabbingOrder

String getTabbingOrder()
Returns the tabbing order as defined in the page description, if present. The tabbing order is used by viewers to determine the tabbing between form fields. The possible values are R for row order, C for column order and S for structure order.

Returns:
A string that holds the entry for the tabbing order from the page description.

getTextSelection

TextSelection getTextSelection(Rectangle2D selectRect)
                               throws PDFException
Deprecated. Use getTextInArea instead

Returns a TextSelection object containing information about any text located in an area. 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. The text selection coordinates will be returned in 'display' space as well, i.e. the origin of the coordinates is page.getCropBox.getX() and page.getCropBox().getY();
Throws:
PDFException

getTextWithCursors

TextSelection getTextWithCursors(Point2D startCursor,
                                 Point2D endCursor)
                                 throws PDFException
Returns the text contained between the start and end cursors, in "reading mode". Reading mode implies line wrapping, column detection and wrapping and more. The effect should be the same as if the user chose the text selection tool, pressed down at the startCursor location and dragged to the endCursor location.

Parameters:
startCursor - the location where the cursor should start selection
endCursor - The location where the cursor ends selection
Returns:
A TextSelection object representing the text that was selected.
Throws:
PDFException

getTextInArea

TextSelection getTextInArea(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. The text selection coordinates will be returned in 'display' space as well, i.e. the origin of the coordinates is page.getCropBox.getX() and page.getCropBox().getY();
Throws:
PDFException

getText

String getText()
               throws PDFException
Returns the text content of this page as a String.

Returns:
The text content of this page.
Throws:
PDFException

getIDocument

IPDFDocument getIDocument()
Returns the document that this page belongs to.

Returns:
The document that this page belongs to.