com.qoppa.pdfProcess
Class PDFPage

java.lang.Object
  extended by com.qoppa.pdfViewer.hiObjects.AbstractPDFPage
      extended by com.qoppa.pdfProcess.PDFPage
All Implemented Interfaces:
IPDFPage

public class PDFPage
extends com.qoppa.pdfViewer.hiObjects.AbstractPDFPage

This class holds a page in a PDF document.

Author:
Qoppa Software

Field Summary
static int COMPRESSION_DEFLATE
           
static int COMPRESSION_JBIG2
           
static int COMPRESSION_JPEG
           
 
Method Summary
 void addAnnotation(Annotation annot)
          Adds a new annotation to this page.
 void addJPEGImage(File jpegFile, int x, int y, AffineTransform xform)
          Adds a JPEG image onto this page.
 SignatureField addSignatureField(String fieldName, Rectangle2D bounds)
          Adds a signature field to this page.
 void appendPageContent(PDFPage srcPage, double x, double y, double scaleX, double scaleY)
          Deprecated. Replaced with appendPageContent(PDFPage, double, double, double, double, Layer)
 void appendPageContent(PDFPage srcPage, double x, double y, double scaleX, double scaleY, Layer layer)
          Adds the content of another page to this page.
 Annotation copyAnnotation(Annotation annot)
          Use this method to copy a single annotation onto this page, from this or other documents.
 void copyAnnotations(PDFPage srcPage)
          Use this method to copy annotations onto this page, from this or other documents.
 void copyAnnotations(PDFPage srcPage, Layer layer)
          Use this method to copy annotations onto this page, from this or other documents.
 Graphics2D createGraphics()
          Creates a Graphics2D object to draw into this page.
 Graphics2D createGraphics(Layer layer)
          Creates a graphics object that encapsulates a layer in a PDF document.
 void deleteAnnotations()
          Delete all annotations from the page.
 void drawImage(Image image, int dstX, int dstY, Color bgndColor, AffineTransform xform, ImageParam params)
          Draws an image onto this page.
 void drawImage(Image image, int dstX, int dstY, int dstWidth, int dstHeight, Color bgndColor, AffineTransform xform, ImageParam params)
          Draws an image onto this page.
 void drawImage(Image image, int dstX, int dstY, int dstWidth, int dstHeight, Color bgndColor, AffineTransform xform, ImageParam params, Float alpha)
          Draws an image onto this page.
 void drawText(String str, Font font, Paint textPaint, double x, double y, AffineTransform xform)
          Draws text onto this page.
 void fillShape(Shape shape, Paint shapePaint, double offsetX, double offsetY, AffineTransform xform)
          Fills a shape on this page.
 Vector findText(String searchText, boolean caseSensitive, boolean wholeWords)
          Searches the page for text and returns a list of TextPosition objects for each of the occurrences of the string in the page.
 Object flattenAnnotation(Annotation annot)
          Flatten an annotation into the content.
 Object flattenAnnotations(boolean paintNonPrintableAnnots)
          Flattens the annotations.
 void flattenWidget(Widget widget)
          Flatten a widget into the content layer of the page.
 PDFDocument getDocument()
          Returns the document that this page belongs to.
 BufferedImage getImage()
          Returns a BufferedImage containing a rendering of the page at the default PDF resolution: 72 DPI.
 BufferedImage getImage(int dpi)
          Returns a BufferedImage containing a rendering of the page at the given resolution in DPI.
 int getPageIndex()
          Gets the page index of this page within the document.
 String getPageLabel()
          Returns the page label for this page.
 double getPaperHeight()
          Returns the paper's height of this page in 72 DPI.
 double getPaperWidth()
          Returns the paper's width of this page in 72 DPI.
 BufferedImage getSubImage(Rectangle2D pageArea, int dpi)
          Returns an image for part of the page.
 TextSelection getTextInArea(Rectangle2D selectArea)
          Selects the text in an area of the page.
 TextSelection getTextWithCursors(Point2D startCursor, Point2D endCursor)
          Returns the text contained between the start and end cursors, in "reading mode".
 void insert_hOCR(String hocrText, boolean renderText)
          This methods inserts hOCR text into this page.
 void invalidate()
          Invalidate paint cache.
 boolean isEmpty()
          Check whether the page is empty.
 void prependPageContent(PDFPage srcPage, double x, double y, double scaleX, double scaleY)
          Deprecated. Replaced with prependPageContent(PDFPage, double, double, double, double, Layer)
 void prependPageContent(PDFPage srcPage, double x, double y, double scaleX, double scaleY, Layer layer)
          Prepend the contents of another page to this page.
 void removeAnnotation(Annotation annot)
          Removes an annotation from this page.
 void replaceContent()
          Rewrite the page's content stream.
 void savePageAsGIF(OutputStream outStream, int dpi)
          Render the page as an image and save it to the output stream in PNG format.
 void savePageAsJPEG(OutputStream outStream, int dpi, float quality)
          Render the page as an image and save it to the output stream in JPEG format.
 void savePageAsPNG(OutputStream outStream, int dpi)
          Render the page as an image and save it to the output stream in PNG format.
 void savePageAsTIFF(OutputStream outStream, double resDPI, String tiffCompression)
          Save the rendering image of the page to the given OutputStream in TIFF format.
 void savePageAsTIFF(OutputStream outStream, TIFFOptions options)
          Render the page to an image and save it in TIFF format to the given OutputStream.
 void setArtBox(Rectangle2D rect)
          Sets this page's Art Box.
 void setBleedBox(Rectangle2D rect)
          Sets this page's Bleed Box.
 void setClip(Area newClip)
          Sets the clip area in the page's content stream when drawing to the page.
 void setCropBox(Rectangle2D rect)
          Sets the PDF page's 'CropBox'.
 void setPageRotation(int degrees)
          Changes this page's rotation.
 void setTrimBox(Rectangle2D rect)
          Sets this page's Trim Box.
 void strokeShape(Shape shape, Paint shapePaint, double offsetX, double offsetY, AffineTransform xform)
          Draws the outline of a shape on this page.
 String useGradientPaint(GradientPaint paint)
           
 String useGState(double strokeAlpha, double fillAlpha, String blendName)
           
 
Methods inherited from class com.qoppa.pdfViewer.hiObjects.AbstractPDFPage
addField, drawAnnotations, findLinesMatchingRegex, findTextWithContext, getAbstractPDFDocument, getAdditionalActions, getAnnotations, getArtBox, getBleedBox, getColorSpace, getCropBox, getDisplayHeight, getDisplayWidth, getDisplayX, getDisplayY, getIDocument, getImage, getImageModel, getImageWithoutText, getMediaBox, getPageRotation, getPageTransForm, getPDFGraphicsOperators, getShapes, getTabbingOrder, getText, getTextModel, getTextSelection, getTrimBox, hasText, invalidateTextModel, moveCaret, pageHasNoText, paintPage, paintPage, paintPageContent, parseToSVG, printPage, setCaret
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COMPRESSION_DEFLATE

public static final int COMPRESSION_DEFLATE
See Also:
Constant Field Values

COMPRESSION_JBIG2

public static final int COMPRESSION_JBIG2
See Also:
Constant Field Values

COMPRESSION_JPEG

public static final int COMPRESSION_JPEG
See Also:
Constant Field Values
Method Detail

addAnnotation

public void addAnnotation(Annotation annot)
                   throws PDFException
Adds a new annotation to this page. This method should only be used with annotations that have been newly created using the AnnotationFactory. It should not be used with existing annotations from this documetn or from other documents. To do this, use the copyAnnotation method.

Parameters:
annot - The annotation to add.
Throws:
PDFException

addJPEGImage

public void addJPEGImage(File jpegFile,
                         int x,
                         int y,
                         AffineTransform xform)
                  throws PDFException,
                         IOException
Adds a JPEG image onto this page.

Parameters:
jpegFile - The JPEG file.
x - The horizontal position of the image in 72 DPI.
y - The vertical position of the image in 72 DPI.
xform - A transform to apply to the image before drawing it to the page. This parameter can be left null for no transform.
Throws:
PDFException
IOException

addSignatureField

public SignatureField addSignatureField(String fieldName,
                                        Rectangle2D bounds)
                                 throws PDFException
Adds a signature field to this page. The signature field is added to the page but is NOT signed. To sign the document, the application must call PDFDocument.signDocument. To create an invisible signature field, the bound rectangle should be set to (0,0,0,0) for the bounds.

Parameters:
fieldName - The name of the new field.
bounds - The bounds of the field on the page. (0,0,0,0) indicates that the signature field will be invisible.
Throws:
PDFException

appendPageContent

public void appendPageContent(PDFPage srcPage,
                              double x,
                              double y,
                              double scaleX,
                              double scaleY)
                       throws PDFException
Deprecated. Replaced with appendPageContent(PDFPage, double, double, double, double, Layer)

Adds the content of another page to this page. This method takes the content stream and directly appends it to this page, without doing any processing. If x and y are set to 0, the source page will be aligned with the destination so that the upper left corners coincide.

Parameters:
srcPage - The source page to take the content stream from.
x - The X position on the destination page at which the upper left corner of the source page will be placed
y - The Y position on the destination page at which the upper left corner of the source page will be placed
scaleX - Horizontal scale to apply to the source page before adding it to the destination page. The scale is 1 based, 1 = full scale.
scaleY - Vertical scale to apply to the source page before adding it to the destination page. The scale is 1 based, 1 = full scale.
Throws:
PDFException

appendPageContent

public void appendPageContent(PDFPage srcPage,
                              double x,
                              double y,
                              double scaleX,
                              double scaleY,
                              Layer layer)
                       throws PDFException
Adds the content of another page to this page. This method takes the content stream and directly appends it to this page without doing any processing. If x and y are set to 0, the source page will be aligned with the destination so that the upper left corners coincide. An optional layer argument can be specified in which to put the source page content.

Parameters:
srcPage - The source page to take the content stream from.
x - The X position on the destination page at which the upper left corner of the source page will be placed.
y - The Y position on the destination page at which the upper left corner of the source page will be placed.
scaleX - Horizontal scale to apply to the source page before adding it to the destination page. The scale is 1 based, 1 = full scale.
scaleY - Vertical scale to apply to the source page before adding it to the destination page. The scale is 1 based, 1 = full scale.
layer - The layer to append the source page content stream, or null.
Throws:
PDFException
IllegalArgumentException - if layer is not null, layer must be from the target document
See Also:
prependPageContent(PDFPage, double, double, double, double, Layer)

copyAnnotation

public Annotation copyAnnotation(Annotation annot)
                          throws PDFException
Use this method to copy a single annotation onto this page, from this or other documents. The method will clone the annotation and then add it to this page. Because this method only copies a single annotation, the copied annotation will lose any associations to other annotations which it had in the previous document; if it was part of a group, it no longer will be.

Returns:
The new annotation.
Throws:
PDFException

copyAnnotations

public void copyAnnotations(PDFPage srcPage)
                     throws PDFException
Use this method to copy annotations onto this page, from this or other documents. The method will clone all annotations (except for widgets/fields) on the source page, and add them to this page. All annotation groupings will be preserved.

Parameters:
srcPage - The source page to copy annotations from
Throws:
PDFException

copyAnnotations

public void copyAnnotations(PDFPage srcPage,
                            Layer layer)
                     throws PDFException
Use this method to copy annotations onto this page, from this or other documents. The method will clone all annotations (except for widgets/fields) on the source page, and add them to this page. All annotation groupings will be preserved. If layer is not null, the layer must belong to this PDFPage's PDFDocument.

Parameters:
srcPage - The source page to copy annotations from
layer - The layer to add the annotations to, may be null
Throws:
PDFException

createGraphics

public Graphics2D createGraphics()
                          throws PDFException
Creates a Graphics2D object to draw into this page. Anything drawn to this graphics object will be drawn onto the PDF page and can then be saved into a PDF document or printed. New content will be drawn on top of the current page content.

The Graphics2D object will initially have its origin on the upper left corner of the page's crop box (the visible area of the page).

Returns:
Graphics2D Graphics object used to draw into this page.
Throws:
PDFException

createGraphics

public Graphics2D createGraphics(Layer layer)
                          throws PDFException
Creates a graphics object that encapsulates a layer in a PDF document. When drawing to this graphics object, all elements will be drawn into a new layer (optional content group) in the pdf document.

The Graphics2D object will initially have its origin on the upper left corner of the page's crop box (the visible area of the page).

Parameters:
layer - The layer to draw into. This object must be created through PDFDocument.addLayer()
Returns:
A Graphics2D object that can be drawn into.
Throws:
PDFException

deleteAnnotations

public void deleteAnnotations()
                       throws PDFException
Delete all annotations from the page. This removes all the annotations in the PDF page. Even though technically, links, widgets (text fields, buttons, etc) and file attachments are annotations, this method does flatten them as they are not annotations in the logical sense.

Throws:
PDFException

drawImage

public void drawImage(Image image,
                      int dstX,
                      int dstY,
                      Color bgndColor,
                      AffineTransform xform,
                      ImageParam params)
               throws PDFException
Draws an image onto this page. The image will be drawn at the specified dstX, dstY location and will not be scaled except for any transform passed into the method.

Parameters:
image - The image to draw.
dstX - The horizontal position of the image in 72 DPI.
dstY - The vertical position of the image in 72 DPI.
bgndColor - The background color if any. If this parameter is not null, the method will first fill a rectangle with this color where the image will be drawn, then draw the image on top.
xform - A transform to apply to the image before drawing it to the page. This parameter can be left null for no transform.
params - An ImageParam object describing what compression to use when writing images to the PDF document. If null, the library will use default settings.
Throws:
PDFException

drawImage

public void drawImage(Image image,
                      int dstX,
                      int dstY,
                      int dstWidth,
                      int dstHeight,
                      Color bgndColor,
                      AffineTransform xform,
                      ImageParam params)
               throws PDFException
Draws an image onto this page. The image will be scaled to dstWidth and dstHeight. If dstWidth or dstHeight are set to 0, the method will get the destination width and/or height from the image size.

Parameters:
image - The image to draw.
dstX - The horizontal position of the image in 72 DPI.
dstY - The vertical position of the image in 72 DPI.
dstWidth - The width on the page that the image will occupy. If this is <= 0, the method will use the image's width.
dstHeight - The height on the page that the image will occupy. If this is <= 0, the method will use the image's height.
bgndColor - The background color if any. If this parameter is not null, the method will first fill a rectangle with this color where the image will be drawn, then draw the image on top.
xform - A transform to apply to the image before drawing it to the page. This parameter can be left null for no transform.
params - An ImageParam object describing what compression to use when writing images to the PDF document. If null, the library will use default settings.
Throws:
PDFException

drawImage

public void drawImage(Image image,
                      int dstX,
                      int dstY,
                      int dstWidth,
                      int dstHeight,
                      Color bgndColor,
                      AffineTransform xform,
                      ImageParam params,
                      Float alpha)
               throws PDFException
Draws an image onto this page. The image will be scaled to dstWidth and dstHeight. If dstWidth or dstHeight are set to 0, the method will get the destination width and/or height from the image size.

Parameters:
image - The image to draw.
dstX - The horizontal position of the image in 72 DPI.
dstY - The vertical position of the image in 72 DPI.
dstWidth - The width on the page that the image will occupy. If this is <= 0, the method will use the image's width.
dstHeight - The height on the page that the image will occupy. If this is <= 0, the method will use the image's height.
bgndColor - The background color if any. If this parameter is not null, the method will first fill a rectangle with this color where the image will be drawn, then draw the image on top.
xform - A transform to apply to the image before drawing it to the page. This parameter can be left null for no transform.
params - An ImageParam object describing what compression to use when writing images to the PDF document. If null, the library will use default settings.
alpha - The alpha component to display the image with transparency
Throws:
PDFException

drawText

public void drawText(String str,
                     Font font,
                     Paint textPaint,
                     double x,
                     double y,
                     AffineTransform xform)
              throws PDFException
Draws text onto this page.

Parameters:
str - The string to draw on the page.
font - The font to use when drawing the text.
textPaint - The color to use when drawing the text.
x - The horizontal position of the text on the page, in 72 DPI.
y - The vertical position of the text on the page, in 72 DPI.
xform - A transform to apply to the text before drawing it to the page.
Throws:
PDFException

fillShape

public void fillShape(Shape shape,
                      Paint shapePaint,
                      double offsetX,
                      double offsetY,
                      AffineTransform xform)
Fills a shape on this page.

Parameters:
shape - The shape to fill.
shapePaint - The color to use when filling the shape.
offsetX - A horizontal offset to apply before drawing the shape, in 72 DPI.
offsetY - A vertical offset to apply before drawing the shape, in 72 DPI.
xform - A transform to apply to the shape before drawing it to the page.

findText

public Vector findText(String searchText,
                       boolean caseSensitive,
                       boolean wholeWords)
                throws PDFException
Searches the page for text and returns a list of TextPosition objects for each of the occurrences of the string in the page. If there are no occurrences, the method returns a Vector of length 0.

Specified by:
findText in interface IPDFPage
Overrides:
findText in class com.qoppa.pdfViewer.hiObjects.AbstractPDFPage
Parameters:
searchText - The text to search for.
caseSensitive - Flag indicating whether the search should be case sensitive.
wholeWords - Flag indicating whether the search should only look at whole words.
Returns:
A list of TextPosition objects.
Throws:
PDFException

getTextWithCursors

public 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.

Specified by:
getTextWithCursors in interface IPDFPage
Overrides:
getTextWithCursors in class com.qoppa.pdfViewer.hiObjects.AbstractPDFPage
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

public 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().

Specified by:
getTextInArea in interface IPDFPage
Overrides:
getTextInArea in class com.qoppa.pdfViewer.hiObjects.AbstractPDFPage
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

flattenAnnotation

public Object flattenAnnotation(Annotation annot)
                         throws PDFException
Flatten an annotation into the content. When an annotation is flattened, it becomes part of the content of the PDF and is not editable anymore.

Parameters:
annot - The annotation to flatten.
Returns:
This method returns an internal object.
Throws:
PDFException

flattenAnnotations

public Object flattenAnnotations(boolean paintNonPrintableAnnots)
                          throws PDFException
Flattens the annotations. This makes the annotations uneditable and merges the content of the annotations with the page. Even though technically, links, widgets (text fields, buttons, etc) and file attachments are annotations, this method does not delete them as they are not annotations in the logical sense. To delete these, the application needs to call the removeAnnotation() method with the annotation as an argument.

Parameters:
paintNonPrintableAnnots - Flag to indicate whether non-printable annotations should be painted or not.
Returns:
This method returns an internal object.
Throws:
PDFException

flattenWidget

public void flattenWidget(Widget widget)
                   throws PDFException
Flatten a widget into the content layer of the page. After flattening the widget, the widget is removed from the list of widgets in the page.

Parameters:
widget - The widget to flatten
Throws:
PDFException

getDocument

public PDFDocument getDocument()
Returns the document that this page belongs to. A PDFPage can only belong to a single document at a time.

Returns:
The parent document.

getImage

public BufferedImage getImage()
                       throws PDFException
Returns a BufferedImage containing a rendering of the page at the default PDF resolution: 72 DPI.

Throws:
PDFException

getImage

public BufferedImage getImage(int dpi)
                       throws PDFException
Returns a BufferedImage containing a rendering of the page at the given resolution in DPI.

Parameters:
dpi - Dots per inch at which to render the image.
Returns:
A BufferedImage object of the page at the requested DPI.
Throws:
PDFException

getPageIndex

public int getPageIndex()
Gets the page index of this page within the document. Page index starts at 0.

Specified by:
getPageIndex in interface IPDFPage
Specified by:
getPageIndex in class com.qoppa.pdfViewer.hiObjects.AbstractPDFPage
Returns:
int This page's index

getPageLabel

public String getPageLabel()
                    throws PDFException
Returns the page label for this page. Labels can be defined in a document to use any string, including for instance roman numerals, or any other labels. This method returns the page label defined for this page, if there is a definition in the document. If there is no definition, this method returns the page number as a string, page numbers start with 1;

Returns:
the page label
Throws:
PDFException

getPaperHeight

public double getPaperHeight()
Returns the paper's height of this page in 72 DPI. This values comes from the page's MediaBox.

Returns:
double Height of this page

getPaperWidth

public double getPaperWidth()
Returns the paper's width of this page in 72 DPI. This values comes from the page's MediaBox.

Returns:
double Width of this page

getSubImage

public BufferedImage getSubImage(Rectangle2D pageArea,
                                 int dpi)
                          throws PDFException
Returns an image for part of the page. The section of the page to get the image for is specified in a rectangle, the resolution of the image is given in the dpi argument.

Parameters:
pageArea - The area of the page to get an image for.
dpi - The desired resolution for the image.
Returns:
A BufferedImage object of the section of the page requested.
Throws:
PDFException

invalidate

public void invalidate()
Invalidate paint cache.


isEmpty

public boolean isEmpty()
                throws PDFException
Check whether the page is empty. An empty page is a page without any content on it.

Returns:
true if the page is empty, false otherwise.
Throws:
PDFException

prependPageContent

public void prependPageContent(PDFPage srcPage,
                               double x,
                               double y,
                               double scaleX,
                               double scaleY)
                        throws PDFException
Deprecated. Replaced with prependPageContent(PDFPage, double, double, double, double, Layer)

Prepend the contents of another page to this page. This method takes the content stream and adds it directly before the current page's content. This will have the effect of adding the content underneath the current content. If x and y are set to 0, the upper left corners of the two pages will coincide.

Parameters:
srcPage - The source page to take the content stream from.
x - The X position on the destination page at which the upper left corner of the source page will be placed
y - The Y position on the destination page at which the upper left corner of the source page will be placed
scaleX - Horizontal scale to apply to the source page before adding it to the destination page.
scaleY - Vertical scale to apply to the source page before adding it to the destination page.
Throws:
PDFException

prependPageContent

public void prependPageContent(PDFPage srcPage,
                               double x,
                               double y,
                               double scaleX,
                               double scaleY,
                               Layer layer)
                        throws PDFException
Prepend the contents of another page to this page. This method takes the content stream and adds it directly before the current page's content. This will have the effect of adding the content underneath the current content. If x and y are set to 0, the upper left corners of the two pages will coincide. An optional layer argument can be specified in which to put the source page content.

Parameters:
srcPage - The source page to take the content stream from.
x - The X position on the destination page at which the upper left corner of the source page will be placed
y - The Y position on the destination page at which the upper left corner of the source page will be placed
scaleX - Horizontal scale to apply to the source page before adding it to the destination page.
scaleY - Vertical scale to apply to the source page before adding it to the destination page.
layer - The layer to append the source page content stream, or null.
Throws:
PDFException
IllegalArgumentException - if layer is not null, layer must be from the target document
See Also:
appendPageContent(PDFPage, double, double, double, double, Layer)

removeAnnotation

public void removeAnnotation(Annotation annot)
                      throws PDFException
Removes an annotation from this page.

Parameters:
annot - A reference to the annotation that needs to be removed.
Throws:
PDFException

savePageAsGIF

public void savePageAsGIF(OutputStream outStream,
                          int dpi)
                   throws PDFException,
                          IOException
Render the page as an image and save it to the output stream in PNG format.

Parameters:
outStream - The stream to save the image to.
dpi - Dots per inch at which to render the image. 72 is the native PDF resolution.
Throws:
PDFException
IOException

savePageAsJPEG

public void savePageAsJPEG(OutputStream outStream,
                           int dpi,
                           float quality)
                    throws IOException,
                           PDFException
Render the page as an image and save it to the output stream in JPEG format.

Parameters:
outStream - The stream to save the image to.
dpi - Dots per inch at which to render the image. 72 is the native PDF resolution.
quality - The quality setting to use for JPEG compression. The range for this value is 0.0 to 1.0. Lower values mean higher compression and lower quality. As a guideline, 0.25 is low quality, 0.5 is medium quality and 0.75 is high quality.
Throws:
IOException
PDFException

savePageAsPNG

public void savePageAsPNG(OutputStream outStream,
                          int dpi)
                   throws PDFException,
                          IOException
Render the page as an image and save it to the output stream in PNG format.

Parameters:
outStream - The stream to save the image to.
dpi - Dots per inch at which to render the image. 72 is the native PDF resolution.
Throws:
PDFException
IOException

savePageAsTIFF

public void savePageAsTIFF(OutputStream outStream,
                           double resDPI,
                           String tiffCompression)
                    throws IOException,
                           PDFException
Save the rendering image of the page to the given OutputStream in TIFF format. The image will be converted to black and white and fax compression will be used. resDPI is the resolution in DPI used to render the page, 72 is the recommended value for the resolution.
This method requires Java Advanced Imaging (JAI) classes in the class path (jai_codec.jar). See our documentation regarding Distribution and JAR Files for more info.

Parameters:
outStream - The stream to save the image to.
resDPI - Dots per inch at which to render the image.
tiffCompression - The type of TIFF compression to use. This value needs to be one of these predefined values:

TIFFOptions.TIFF_DEFLATE - Deflate lossless compression (Zip-in-TIFF)
TIFFOptions.TIFF_CCITT_RLE - CCITT Modified Huffman RLE
TIFFOptions.TIFF_CCITT_T4 - CCITT Group 3 fax encoding
TIFFOptions.TIFF_CCITT_T6 - CCITT Group 4 fax encoding
TIFFOptions.TIFF_JPEG - JPEG-in-TIFF compression.
TIFFOptions.TIFF_LZW - LZW Compression
TIFFOptions.TIFF_PACKBITS - Byte-oriented run-length encoding "PackBits" compression.
TIFFOptions.TIFF_ZLIB - ZLib Compression.
TIFFOptions.TIFF_NO_COMPRESSION - No compression.
Throws:
IOException
PDFException

savePageAsTIFF

public void savePageAsTIFF(OutputStream outStream,
                           TIFFOptions options)
                    throws IOException,
                           PDFException
Render the page to an image and save it in TIFF format to the given OutputStream. If fax compression is used, the image will be converted automatically to black and white.
This method requires Java Advanced Imaging (JAI) classes in the class path (jai_codec.jar). See our documentation regarding Distribution and JAR Files for more info.

Parameters:
outStream - The stream to save the image to.
options - Options when saving the image, such as the output DPI, the TIFF compression method and more.
Throws:
IOException
PDFException

setArtBox

public void setArtBox(Rectangle2D rect)
Sets this page's Art Box. The art box defines the extent of the page's meaningful content (including potential whitespace). This rectangle is in PDF native coordinates starting at the bottom left and increasing up to the right.


setBleedBox

public void setBleedBox(Rectangle2D rect)
Sets this page's Bleed Box. A page should be clipped to this coordinates when output to a production environment. This rectangle is in PDF native coordinates starting at the bottom left and increasing up to the right.


setClip

public void setClip(Area newClip)
             throws PDFException
Sets the clip area in the page's content stream when drawing to the page.

Parameters:
newClip - The new clip area.
Throws:
PDFException

setCropBox

public void setCropBox(Rectangle2D rect)
                throws PDFException
Sets the PDF page's 'CropBox'. The CropBox is a rectangle that is used to crop content before displaying or printing the page. This rectangle is in PDF native coordinates starting at the bottom left and increasing up to the right.

Throws:
PDFException

setPageRotation

public void setPageRotation(int degrees)
                     throws PDFException
Changes this page's rotation.

Parameters:
degrees - The new page rotation, in degrees
Throws:
PDFException

setTrimBox

public void setTrimBox(Rectangle2D rect)
Sets this page's Trim Box. The trim box defines a finished page's intended dimension after trimming. This rectangle is in PDF native coordinates starting at the bottom left and increasing up to the right.


strokeShape

public void strokeShape(Shape shape,
                        Paint shapePaint,
                        double offsetX,
                        double offsetY,
                        AffineTransform xform)
Draws the outline of a shape on this page.

Parameters:
shape - The shape whose outline will be drawn.
shapePaint - The color to use when drawing the outline of the shape.
offsetX - A horizontal offset to apply before drawing the shape, in 72 DPI.
offsetY - A vertical offset to apply before drawing the shape, in 72 DPI.
xform - A transform to apply to the shape before drawing it to the page.

useGradientPaint

public String useGradientPaint(GradientPaint paint)
                        throws PDFException
Throws:
PDFException

useGState

public String useGState(double strokeAlpha,
                        double fillAlpha,
                        String blendName)
                 throws PDFException
Throws:
PDFException

replaceContent

public void replaceContent()
                    throws PDFException
Rewrite the page's content stream. This is generally not recommended for use.

Throws:
PDFException

insert_hOCR

public void insert_hOCR(String hocrText,
                        boolean renderText)
                 throws PDFException
This methods inserts hOCR text into this page. hOCR is an open standard that defines a data format representation of OCR results. The hOCR standard is supported by a number of OCR engines, including Tesseract, Cuneiform and OCRopus. This method will take hOCR content and insert the text content into the page.

This function is an optional component for Qoppa Software's PDF libraries, it requires separate licensing. If the method is called without being licensed, OCR will be performed and all text results inserted into the page, but the method will add a watermark to the page.

Parameters:
hocrText - The hOCR text content.
renderText - Flag indicating whethet the text should be shown on the page. If the flag is false, the text is added in "No Render" mode. Text that uses this mode is present in the page and it is selectable, but it is not visible.
Throws:
PDFException