|
Gnostice PDFOne Java
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.gnostice.pdfone.PdfPage
public final class PdfPage
This class represents a PDF page. PdfPage offers
numerous methods to work with elements such as text, shapes,
images, annotations, and bookmarks.
After content is written to a page, it is usually added to a
PdfDocument object using the
PdfDocument.add(PdfPage) method. A
PdfPage object can be cloned using the
clone() method and then added to a
PdfDocument one more time. However, the
same PdfPage object can be added to multiple
PdfDocument object without cloning.
// Creates several PdfDocument objects PdfDocument doc1 = ... PdfDocument doc2 = ... PdfDocument doc1 = ... ... PdfDocument docn = ... // Creates a PdfPage object PdfPage page = new PdfPage(); // Performs operations with the above PdfPage object ... // Adds the same PdfPage object to the PdfDocument objects // created above doc1.add(page); doc2.add(page); doc3.add(page); ... docn.add(page); ...
While writing to a page, the position where the content should appear is very important. The coordinates of the position is always made in reference to the top-left corner the page. Whenever coordinates, position, or sizes are used, they are usually applied in terms of the page's current measurement unit, which can be centimeters, inches, pixels, points, and twips. However, in situations where a measurement unit cannot be applied or determined, the measurement unit will be by default points.
Every page has a default pen setting and a default brush setting. The pen for example is used to stroke the borders when a rectangle is drawn. In the same example, the brush would be used when the area bounded by the rectangle is filled.
| Field Summary | |
|---|---|
static int |
COLORSPACE_CMYK
|
static int |
COLORSPACE_RGB
|
static int |
HP_LEFT
Constant to specify horizontal alignment to the left (inside header, footer and watermarks) |
static int |
HP_MIDDLE
Constant to specify horizontal alignment to the middle (inside header, footer and watermarks) |
static int |
HP_RIGHT
Constant to specify horizontal alignment to the right (inside header, footer and watermarks) |
static boolean |
OVERLAY
Constant to specify z-order overlay |
static boolean |
UNDERLAY
Constant to specify z-order underlay |
static int |
VP_BOTTOM
Constant to specify vertical alignment to the bottom (inside header, footer and watermarks) |
static int |
VP_CENTRE
Constant to specify vertical alignment to the center (inside header, footer and watermarks) |
static int |
VP_TOP
Constant to specify vertical alignment to the top (inside header, footer and watermarks) |
| Constructor Summary | |
|---|---|
PdfPage()
Zero-argument default constructor. |
|
PdfPage(double width,
double height)
Constructs a page with specified width and height. |
|
PdfPage(double width,
double height,
double pageHeaderHeight,
double pageFooterHeight,
double pageLeftMargin,
double pageTopMargin,
double pageRightMargin,
double pageBottomMargin,
int measurementUnit)
Constructs a page with its width, height, header height, footer height, and margins specified in measurementUnit
units. |
|
PdfPage(double width,
double height,
double pageLeftMargin,
double pageTopMargin,
double pageRightMargin,
double pageBottomMargin,
int measurementUnit)
Constructs a page with its width, height, and margins specified in measurementUnit units. |
|
PdfPage(double width,
double height,
int measurementUnit)
Constructs a page with its width and height specified in measurementUnit units. |
|
PdfPage(int pageSize)
Constructs a page with specified size. |
|
PdfPage(int pageSize,
double pageHeaderHeight,
double pageFooterHeight,
double pageLeftMargin,
double pageTopMargin,
double pageRightMargin,
double pageBottomMargin,
int measurementUnit)
Constructs a page with its size, header height, footer height, and margins specified in measurementUnit units. |
|
PdfPage(int pageSize,
double pageLeftMargin,
double pageTopMargin,
double pageRightMargin,
double pageBottomMargin,
int measurementUnit)
Constructs a page with its size and margins specified in measurementUnit units. |
|
| Method Summary | |
|---|---|
void |
addAction(int event,
int namedAction)
Adds specified named action for specified trigger event. |
void |
addAction(int event,
int actionType,
String javascriptOrURI)
Adds action of resolving specified Uniform Resource Identifier URI) or executing a JavaScript script for the specified event. |
void |
addAction(int event,
int actionType,
String applicationToLaunch,
boolean isPrint)
Adds action of launching specified application, or displaying or printing specified file for the specified event. |
void |
addAnnotation(PdfAnnot annotation)
Adds specified annotation to this PdfPage. |
void |
addAnnotationList(List annotList)
|
void |
addAnnotationList(List annotList,
boolean removeExistingAnnots)
|
void |
addFooterImage(PdfImage img,
int position,
boolean underlay)
Adds PdfImage object to footer. |
void |
addFooterImage(String path,
int position,
boolean underlay)
Adds image, specified by its pathname, to footer. |
void |
addFooterText(String text,
PdfFont font,
int position,
boolean underlay)
Adds specified text to footer. |
void |
addFooterText(String text,
PdfFont font,
PdfRect rect,
int alignment,
int firstLinePosition,
int position,
boolean underlay)
Adds specified text to footer. |
void |
addFormField(PdfFormField f)
Adds specified form field to page. |
void |
addFormFieldList(List formFieldList)
|
void |
addHeaderImage(PdfImage img,
int position,
boolean underlay)
Adds PdfImage object to the header. |
void |
addHeaderImage(String path,
int position,
boolean underlay)
Adds image, specified by its pathname, to header. |
void |
addHeaderText(String text,
PdfFont font,
int position,
boolean underlay)
Adds specified text to header. |
void |
addHeaderText(String text,
PdfFont font,
PdfRect rect,
int alignment,
int firstLinePosition,
int position,
boolean underlay)
Adds specified text to footer. |
void |
addTable(PdfTable table,
double x,
double y)
|
void |
addTable(PdfTable table,
PdfFont f,
double x,
double y)
|
void |
addThumbnailImage(String path)
|
void |
addWatermarkImage(PdfImage image,
int position,
boolean applyMargins,
double angle,
boolean underlay)
Adds PdfImage object as watermark image with its
exact position determined by position and
applyMargins. |
void |
addWatermarkImage(PdfImage image,
int position,
double angle,
boolean underlay)
Adds PdfImage object as watermark image. |
void |
addWatermarkImage(String path,
int position,
boolean applyMargins,
double angle,
boolean underlay)
Adds image, specified by its pathname, as watermark image with its exact position determined by position
and applyMargins. |
void |
addWatermarkImage(String path,
int position,
double angle,
boolean underlay)
Adds image, specified by its pathname, as watermark image. |
void |
addWatermarkText(String text,
PdfFont font,
int position,
boolean applyMargins,
double angle,
boolean underlay)
Adds specified text as watermark with its exact position determined by position and
applyMargins. |
void |
addWatermarkText(String text,
PdfFont font,
int position,
double angle,
boolean underlay)
Adds specified text as watermark. |
void |
addWatermarkText(String text,
PdfFont font,
PdfRect rect,
int alignment,
int firstLinePosition,
int position,
double angle,
boolean underlay)
Adds specified text as a watermark to a specified rectangular area with specified font, alignment, first-line position, position, rotation, and underlay settings. |
Object |
clone()
|
void |
deleteFormFields()
|
void |
deleteFormFields(int type)
|
void |
deleteFormFields(String name)
|
void |
disableAllMargins()
Disables all margins on this PdfPage. |
void |
drawArc(PdfRect rect,
double startAngle,
double sweepAngle)
Draws an arc. |
void |
drawBezierCurve(double startX,
double startY,
double ctrlX,
double ctrlY,
double endX,
double endY,
boolean isFill,
boolean isStroke)
Draws a Bézier curve with a control point specified by ( ctrlX, ctrlY). |
void |
drawBezierCurve(double startX,
double startY,
double ctrlX1,
double ctrlY1,
double ctrlX2,
double ctrlY2,
double endX,
double endY,
boolean isFill,
boolean isStroke)
Draws a Bézier curve with control points at ( ctrlX1, ctrlY1) and
(ctrlX2, ctrlY2). |
void |
drawBezierCurve(PdfPoint start,
PdfPoint control,
PdfPoint end,
boolean isFill,
boolean isStroke)
Draws a Bézier curve with a single control point. |
void |
drawBezierCurve(PdfPoint start,
PdfPoint controlPoint1,
PdfPoint controlPoint2,
PdfPoint end,
boolean isFill,
boolean isStroke)
Draws a Bézier curve with two control points. |
void |
drawCircle(double x,
double y,
double radius,
boolean isFill,
boolean isStroke)
Draws a circle with its center at position ( x, y). |
void |
drawCircle(PdfPoint center,
double radius,
boolean isFill,
boolean isStroke)
Draws a circle with its center at the specified point. |
void |
drawEllipse(double x1,
double y1,
double x2,
double y2,
boolean isFill,
boolean isStroke)
Draws an ellipse whose bounding box has its top-left corner at ( x1, y1) and its bottom-right
corner at (x2, y2). |
void |
drawEllipse(PdfPoint p1,
PdfPoint p2,
boolean isFill,
boolean isStroke)
Draws an ellipse whose bounding box has its top-left corner at point1 and its bottom-right corner at
point2. |
void |
drawImage(PdfImage img,
double x,
double y)
Draws specified image at position ( x,
y). |
void |
drawImage(PdfImage img,
double x,
double y,
double rotation)
Draws specified image, rotated by rotation
degrees, at position (x, y). |
void |
drawImage(PdfImage img,
double x,
double y,
double width,
double height)
Draws specified image at position ( x,
y) with specified width and height. |
void |
drawImage(PdfImage img,
double x,
double y,
double width,
double height,
double rotation)
Draw specified image, rotated by rotation
degrees, at position (x, y)
with specified height and width. |
void |
drawImage(PdfImage img,
PdfPoint p)
Draws specified image at specified point. |
void |
drawImage(PdfImage img,
PdfPoint p,
double rotation)
Draws specified image, rotated by rotation
degrees, at point p. |
void |
drawImage(PdfImage img,
PdfPoint p,
double width,
double height)
Draws specified image at point p with specified
width and height. |
void |
drawImage(PdfImage img,
PdfPoint p,
double width,
double height,
double rotation)
Draws specified image, rotated by rotation
degrees, at point p with specified width and
height. |
void |
drawImage(PdfImage img,
PdfRect rect)
Draws specified image on specified rectangle. |
void |
drawImage(PdfImage img,
PdfRect rect,
double rotation)
Draws specified image, rotated by rotation
degrees, on specified rectangle. |
void |
drawImage(String path,
double x,
double y)
Draws image, specified by its pathname, at position ( x, y). |
void |
drawImage(String path,
double x,
double y,
double rotation)
Draw image, specified by its pathname and rotated by rotation degrees, at position (x,
y). |
void |
drawImage(String path,
double x,
double y,
double width,
double height)
Draws image, specified by its pathname, at position ( x,
y) with specified width and height. |
void |
drawImage(String path,
double x,
double y,
double width,
double height,
double rotation)
Draws image, specified by its pathname and rotated by rotation degrees, at position (x,
y) with specified width and height. |
void |
drawImage(String path,
PdfPoint p)
Draws image, specified by its pathname, at point p. |
void |
drawImage(String path,
PdfPoint p,
double rotation)
Draws image, specified by its pathname and rotated by rotation degrees, at point p. |
void |
drawImage(String path,
PdfPoint p,
double width,
double height)
Draws image, specified by its pathname, at point p with specified width and height. |
void |
drawImage(String path,
PdfPoint p,
double width,
double height,
double rotation)
Draws image, specified by its pathname and rotated by rotation degrees, at point p with
specified width and height. |
void |
drawImage(String path,
PdfRect rect)
Draws image, specified by its pathname, on rectangle rect. |
void |
drawImage(String path,
PdfRect rect,
double rotation)
Draws image, specified by its pathname and rotated by rotation degrees, on rectangle
rect. |
void |
drawLine(double startx,
double starty,
double endx,
double endy)
Draws a line between positions ( startx, starty) and
(endx, endy). |
void |
drawLine(PdfPoint start,
PdfPoint end)
Draws a line between points start and
end. |
void |
drawPie(double x,
double y,
double width,
double height,
double startAngle,
double sweepAngle,
boolean isFill,
boolean isStroke)
Draws a pie segment. |
void |
drawPolygon(double[] xPoints,
double[] yPoints,
int nPoints,
boolean isFill,
boolean isStroke)
Draws a polygon. |
void |
drawPolyline(double[] xPoints,
double[] yPoints,
int nPoints)
Draws a polyline. |
void |
drawRect(double x,
double y,
double width,
double height)
Draws a rectangle at position ( x, y)
with specified width and height. |
void |
drawRect(double x,
double y,
double width,
double height,
boolean isFill,
boolean isStroke)
Draws a rectangle at position ( x, y)
with specified width, height, brush, and pen settings. |
void |
drawRect(PdfPoint p,
double width,
double height)
Draws a rectangle at specified point with specified width and height. |
void |
drawRect(PdfPoint p,
double width,
double height,
boolean isFill,
boolean isStroke)
Draws a rectangle at specified point with specified width, height, brush, and pen settings. |
void |
drawRect(PdfRect r)
Draws a rectangle. |
void |
drawRect(Rectangle r)
|
void |
drawRoundRect(double x,
double y,
double width,
double height,
double arcWidth,
double arcHeight,
boolean isFill,
boolean isStroke)
Draws a rectangle with rounded corners. |
void |
drawRoundRect(PdfRect rect,
double arcWidth,
double arcHeight,
boolean isFill,
boolean isStroke)
Draws rectangle rect with specified rounded
corners. |
void |
drawSquare(double x,
double y,
double length)
Draws a square at position ( x, y). |
void |
drawSquare(double x,
double y,
double length,
boolean isFill,
boolean isStroke)
Draws a square at position ( x, y)
with specified fill and stroke settings. |
void |
drawSquare(PdfPoint p,
double length)
Draws a square at point p. |
void |
drawSquare(PdfPoint p,
double length,
boolean isFill,
boolean isStroke)
Draws a square at point p with specified fill
and stroke settings. |
void |
enableAllMargins()
Enables all margins on this PdfPage. |
void |
flattenFormFields()
|
void |
flattenFormFields(boolean flattenWithNewValue)
|
void |
flattenFormFields(int type)
|
void |
flattenFormFields(int type,
boolean flattenWithNewValue)
|
void |
flattenFormFields(String name)
|
void |
flattenFormFields(String name,
boolean flattenWithNewValue)
|
List |
getAllAnnotations()
|
List |
getAllAnnotations(int type)
|
void |
getAllAnnotations(int type,
List listToPopulate)
|
void |
getAllAnnotations(List listToPopulate)
|
List |
getAllFontBaseNames()
|
List |
getAllFormFields()
Returns a list of all form fields in the page. |
List |
getAllFormFields(int type)
Returns a list of all form fields of specified type in the page. |
List |
getAllFormFields(String name)
Returns a list of all form fields with specified name in the page. |
double |
getBottomMargin()
Returns size of this page's bottom margin. |
PdfBrush |
getBrush()
Returns default brush used on this page. |
int |
getColorSpace()
|
double |
getCropBottom()
Returns difference between bottom boundaries of this page's media box and crop box. |
double |
getCropLeft()
Returns difference between left boundaries of this page's media box and crop box. |
double |
getCropRight()
Returns difference between right boundaries of this page's media box and crop box. |
double |
getCropTop()
Returns difference between top boundaries of this page's media box and crop box. |
double |
getDisplayDuration()
|
PdfFont |
getFont()
Returns default font used to render text elements on this page. |
double |
getFooterHeight()
Returns height of this page's footer. |
double |
getHeaderHeight()
Returns height of this page's footer. |
double |
getHeight()
Returns height of this page. |
double |
getLeftMargin()
Returns size of this page's left margin. |
int |
getMeasurementUnit()
Returns default measurement unit currently used for this PdfPage. |
PdfPen |
getPen()
Returns a PdfPen object representing this page's
pen. |
PdfPagePresentation |
getPresentation()
|
double |
getRightMargin()
Returns size of this page's right margin. |
int |
getRotation()
Returns angle of rotation for contents of this page. |
PdfTextFormatter |
getTextFormatter()
Retrieves PdfTextFormatter object contained by
this PdfPage. |
double |
getTopMargin()
Returns the size of this page's top margin. |
double |
getWidth()
Returns width of this page. |
void |
removeThumbnailImage()
|
void |
setBrush(PdfBrush brush)
|
void |
setBrushColor(Color c)
Specifies default color for this page's brush. |
void |
setColorSpace(int colorspace)
|
void |
setCph(PdfCustomPlaceholderHandler cph)
|
void |
setDisplayDuration(double displayDuration)
|
void |
setFont(PdfFont font)
Specifies a default font that needs to be used render text elements on this page. |
void |
setHeight(double height,
int unit)
|
void |
setMeasurementUnit(int mu)
Specifies default measurement unit to be used for this PdfPage. |
void |
setPen(PdfPen pen)
Sets specified PdfPen object as this page's pen. |
void |
setPenCapStyle(int capStyle)
Specifies default shape of endpoints of paths in this page. |
void |
setPenColor(Color color)
Specifies default color for this page's pen. |
void |
setPenDashGap(double gap)
Specifies length of gaps in default dash pattern of this page's pen. |
void |
setPenDashLength(double length)
Specifies length of dashes in default dash pattern of this PdfDocument's pen. |
void |
setPenDashPhase(double phase)
Specifies length of phase of default dash pattern of this page's pen. |
void |
setPenJoinStyle(int joinStyle)
Specifies default shape of joints of paths that connect at an angle for this pages's pen. |
void |
setPenMiterLimit(int limit)
Specifies default miter limit for this page's pen. |
void |
setPenWidth(double width)
Specifies default width for this page's pen. |
void |
setPresentation(PdfPagePresentation presentation)
|
void |
setTextFormatter(PdfTextFormatter tf)
Specifies new text formatting settings. |
void |
setWidth(double width,
int unit)
|
void |
writeText(String str)
Writes specified text on this PdfPage. |
void |
writeText(String str,
boolean wrap)
Writes text str with specified wrap setting on
this |
void |
writeText(String str,
double x,
double y)
Writes text str at position (x,
y). |
void |
writeText(String str,
double x,
double y,
boolean wrap)
Writes text str at position
(x, y) with specified wrap setting. |
void |
writeText(String str,
double x,
double y,
double rotation)
Writes text str, rotated by
rotation degrees, at position (x,
y). |
void |
writeText(String str,
double x,
double y,
int alignment)
Writes text str at position (x,
|