java.io.Closeable
, java.lang.AutoCloseable
public class PDPageContentStream
extends java.lang.Object
implements java.io.Closeable
Constructor | Description |
---|---|
PDPageContentStream(PDDocument document,
PDPage sourcePage) |
Create a new PDPage content stream.
|
PDPageContentStream(PDDocument document,
PDPage sourcePage,
boolean appendContent,
boolean compress) |
Create a new PDPage content stream.
|
PDPageContentStream(PDDocument document,
PDPage sourcePage,
boolean appendContent,
boolean compress,
boolean resetContext) |
Create a new PDPage content stream.
|
Modifier and Type | Method | Description |
---|---|---|
void |
addBezier31(float x1,
float y1,
float x3,
float y3) |
Append a cubic B??zier curve to the current path.
|
void |
addBezier312(float x1,
float y1,
float x2,
float y2,
float x3,
float y3) |
Append a cubic B??zier curve to the current path.
|
void |
addBezier32(float x2,
float y2,
float x3,
float y3) |
Append a cubic B??zier curve to the current path.
|
void |
addLine(float xStart,
float yStart,
float xEnd,
float yEnd) |
add a line to the current path.
|
void |
addPolygon(float[] x,
float[] y) |
Add a polygon to the current path.
|
void |
addRect(float x,
float y,
float width,
float height) |
Add a rectangle to the current path.
|
void |
appendCOSName(COSName name) |
This will append a
COSName to the content stream. |
void |
appendRawCommands(byte[] commands) |
This will append raw commands to the content stream.
|
void |
appendRawCommands(double data) |
This will append raw commands to the content stream.
|
void |
appendRawCommands(float data) |
This will append raw commands to the content stream.
|
void |
appendRawCommands(int data) |
This will append raw commands to the content stream.
|
void |
appendRawCommands(java.lang.String commands) |
This will append raw commands to the content stream.
|
void |
beginMarkedContentSequence(COSName tag) |
Begin a marked content sequence.
|
void |
beginMarkedContentSequence(COSName tag,
COSName propsName) |
Begin a marked content sequence with a reference to an entry in the page resources'
Properties dictionary.
|
void |
beginText() |
Begin some text operations.
|
void |
clipPath(int windingRule) |
Clip path.
|
void |
close() |
Close the content stream.
|
void |
closeAndStroke() |
Close and stroke the path.
|
void |
closeSubPath() |
Close subpath.
|
void |
concatenate2CTM(double a,
double b,
double c,
double d,
double e,
double f) |
The Cm operator.
|
void |
concatenate2CTM(java.awt.geom.AffineTransform at) |
The Cm operator.
|
void |
drawImage(PDXObjectImage image,
float x,
float y) |
Draw an image at the x,y coordinates, with the default size of the image.
|
void |
drawLine(float xStart,
float yStart,
float xEnd,
float yEnd) |
Draw a line on the page using the current non stroking color and the current line width.
|
void |
drawPolygon(float[] x,
float[] y) |
Draw a polygon on the page using the current non stroking color.
|
void |
drawString(java.lang.String text) |
This will draw a string at the current location on the screen.
|
void |
drawXObject(PDXObject xobject,
float x,
float y,
float width,
float height) |
Draw an xobject(form or image) at the x,y coordinates and a certain width and height.
|
void |
drawXObject(PDXObject xobject,
java.awt.geom.AffineTransform transform) |
Draw an xobject(form or image) using the given
AffineTransform to position
the xobject. |
void |
endMarkedContentSequence() |
End a marked content sequence.
|
void |
endText() |
End some text operations.
|
void |
fill(int windingRule) |
Fill the path.
|
void |
fillPolygon(float[] x,
float[] y) |
Draw and fill a polygon on the page using the current non stroking color.
|
void |
fillRect(float x,
float y,
float width,
float height) |
Draw a rectangle on the page using the current non stroking color.
|
void |
lineTo(float x,
float y) |
Add a move to the given coordinate.
|
void |
moveTextPositionByAmount(float x,
float y) |
The Td operator.
|
void |
moveTo(float x,
float y) |
Add a line to the given coordinate.
|
void |
restoreGraphicsState() |
Q operator.
|
void |
saveGraphicsState() |
q operator.
|
void |
setFont(PDFont font,
float fontSize) |
Set the font to draw text with.
|
void |
setLineCapStyle(int lineCapStyle) |
Set the line cap style.
|
void |
setLineDashPattern(float[] pattern,
float phase) |
Set the line dash pattern.
|
void |
setLineJoinStyle(int lineJoinStyle) |
Set the line join style.
|
void |
setLineWidth(float lineWidth) |
Set linewidth to the given value.
|
void |
setNonStrokingColor(double g) |
Set the non stroking color, specified as Grayscale 0.0-1.0.
|
void |
setNonStrokingColor(double c,
double m,
double y,
double k) |
Set the non stroking color, specified as CMYK, 0.0-1.0.
|
void |
setNonStrokingColor(float[] components) |
Set the color components of current non stroking colorspace.
|
void |
setNonStrokingColor(int g) |
Set the non stroking color, specified as grayscale, 0-255.
|
void |
setNonStrokingColor(int r,
int g,
int b) |
Set the non stroking color, specified as RGB, 0-255.
|
void |
setNonStrokingColor(int c,
int m,
int y,
int k) |
Set the non stroking color, specified as CMYK, 0-255.
|
void |
setNonStrokingColor(java.awt.Color color) |
Set the non stroking color, specified as RGB.
|
void |
setNonStrokingColorSpace(PDColorSpace colorSpace) |
Set the stroking color space.
|
void |
setStrokingColor(double g) |
Set the stroking color, specified as Grayscale 0.0-1.0.
|
void |
setStrokingColor(double c,
double m,
double y,
double k) |
Set the stroking color, specified as CMYK, 0.0-1.0.
|
void |
setStrokingColor(float[] components) |
Set the color components of current stroking colorspace.
|
void |
setStrokingColor(int g) |
Set the stroking color, specified as grayscale, 0-255.
|
void |
setStrokingColor(int r,
int g,
int b) |
Set the stroking color, specified as RGB, 0-255.
|
void |
setStrokingColor(int c,
int m,
int y,
int k) |
Set the stroking color, specified as CMYK, 0-255.
|
void |
setStrokingColor(java.awt.Color color) |
Set the stroking color, specified as RGB.
|
void |
setStrokingColorSpace(PDColorSpace colorSpace) |
Set the stroking color space.
|
void |
setTextMatrix(double a,
double b,
double c,
double d,
double e,
double f) |
The Tm operator.
|
void |
setTextMatrix(java.awt.geom.AffineTransform matrix) |
The Tm operator.
|
void |
setTextRotation(double angle,
double tx,
double ty) |
The Tm operator.
|
void |
setTextScaling(double sx,
double sy,
double tx,
double ty) |
The Tm operator.
|
void |
setTextTranslation(double tx,
double ty) |
The Tm operator.
|
void |
stroke() |
Stroke the path.
|
public PDPageContentStream(PDDocument document, PDPage sourcePage) throws java.io.IOException
document
- The document the page is part of.sourcePage
- The page to write the contents to.java.io.IOException
- If there is an error writing to the page contents.public PDPageContentStream(PDDocument document, PDPage sourcePage, boolean appendContent, boolean compress) throws java.io.IOException
document
- The document the page is part of.sourcePage
- The page to write the contents to.appendContent
- Indicates whether content will be overwritten. If false all previous content is deleted.compress
- Tell if the content stream should compress the page contents.java.io.IOException
- If there is an error writing to the page contents.public PDPageContentStream(PDDocument document, PDPage sourcePage, boolean appendContent, boolean compress, boolean resetContext) throws java.io.IOException
document
- The document the page is part of.sourcePage
- The page to write the contents to.appendContent
- Indicates whether content will be overwritten. If false all previous content is deleted.compress
- Tell if the content stream should compress the page contents.resetContext
- Tell if the graphic context should be reseted.java.io.IOException
- If there is an error writing to the page contents.public void beginText() throws java.io.IOException
java.io.IOException
- If there is an error writing to the stream or if you attempt to
nest beginText calls.public void endText() throws java.io.IOException
java.io.IOException
- If there is an error writing to the stream or if you attempt to
nest endText calls.public void setFont(PDFont font, float fontSize) throws java.io.IOException
font
- The font to use.fontSize
- The font size to draw the text.java.io.IOException
- If there is an error writing the font information.public void drawImage(PDXObjectImage image, float x, float y) throws java.io.IOException
image
- The image to draw.x
- The x-coordinate to draw the image.y
- The y-coordinate to draw the image.java.io.IOException
- If there is an error writing to the stream.public void drawXObject(PDXObject xobject, float x, float y, float width, float height) throws java.io.IOException
xobject
- The xobject to draw.x
- The x-coordinate to draw the image.y
- The y-coordinate to draw the image.width
- The width of the image to draw.height
- The height of the image to draw.java.io.IOException
- If there is an error writing to the stream.public void drawXObject(PDXObject xobject, java.awt.geom.AffineTransform transform) throws java.io.IOException
AffineTransform
to position
the xobject.xobject
- The xobject to draw.transform
- the transformation matrixjava.io.IOException
- If there is an error writing to the stream.public void moveTextPositionByAmount(float x, float y) throws java.io.IOException
x
- The x coordinate.y
- The y coordinate.java.io.IOException
- If there is an error writing to the stream.public void setTextMatrix(double a, double b, double c, double d, double e, double f) throws java.io.IOException
a
- The a value of the matrix.b
- The b value of the matrix.c
- The c value of the matrix.d
- The d value of the matrix.e
- The e value of the matrix.f
- The f value of the matrix.java.io.IOException
- If there is an error writing to the stream.public void setTextMatrix(java.awt.geom.AffineTransform matrix) throws java.io.IOException
matrix
- the transformation matrixjava.io.IOException
- If there is an error writing to the stream.public void setTextScaling(double sx, double sy, double tx, double ty) throws java.io.IOException
sx
- The scaling factor in x-direction.sy
- The scaling factor in y-direction.tx
- The translation value in x-direction.ty
- The translation value in y-direction.java.io.IOException
- If there is an error writing to the stream.public void setTextTranslation(double tx, double ty) throws java.io.IOException
tx
- The translation value in x-direction.ty
- The translation value in y-direction.java.io.IOException
- If there is an error writing to the stream.public void setTextRotation(double angle, double tx, double ty) throws java.io.IOException
angle
- The angle used for the counterclockwise rotation in radians.tx
- The translation value in x-direction.ty
- The translation value in y-direction.java.io.IOException
- If there is an error writing to the stream.public void concatenate2CTM(double a, double b, double c, double d, double e, double f) throws java.io.IOException
a
- The a value of the matrix.b
- The b value of the matrix.c
- The c value of the matrix.d
- The d value of the matrix.e
- The e value of the matrix.f
- The f value of the matrix.java.io.IOException
- If there is an error writing to the stream.public void concatenate2CTM(java.awt.geom.AffineTransform at) throws java.io.IOException
AffineTransform
.at
- the transformation matrixjava.io.IOException
- If there is an error writing to the stream.public void drawString(java.lang.String text) throws java.io.IOException
text
- The text to draw.java.io.IOException
- If an io exception occurs.public void setStrokingColorSpace(PDColorSpace colorSpace) throws java.io.IOException
colorSpace
- The colorspace to write.java.io.IOException
- If there is an error writing the colorspace.public void setNonStrokingColorSpace(PDColorSpace colorSpace) throws java.io.IOException
colorSpace
- The colorspace to write.java.io.IOException
- If there is an error writing the colorspace.public void setStrokingColor(float[] components) throws java.io.IOException
components
- The components to set for the current color.java.io.IOException
- If there is an error while writing to the stream.public void setStrokingColor(java.awt.Color color) throws java.io.IOException
color
- The color to set.java.io.IOException
- If an IO error occurs while writing to the stream.public void setNonStrokingColor(java.awt.Color color) throws java.io.IOException
color
- The color to set.java.io.IOException
- If an IO error occurs while writing to the stream.public void setStrokingColor(int r, int g, int b) throws java.io.IOException
r
- The red value.g
- The green value.b
- The blue value.java.io.IOException
- If an IO error occurs while writing to the stream.java.lang.IllegalArgumentException
- If the parameters are invalid.public void setStrokingColor(int c, int m, int y, int k) throws java.io.IOException
c
- The cyan value.m
- The magenta value.y
- The yellow value.k
- The black value.java.io.IOException
- If an IO error occurs while writing to the stream.java.lang.IllegalArgumentException
- If the parameters are invalid.public void setStrokingColor(double c, double m, double y, double k) throws java.io.IOException
c
- The cyan value.m
- The magenta value.y
- The yellow value.k
- The black value.java.io.IOException
- If an IO error occurs while writing to the stream.java.lang.IllegalArgumentException
- If the parameters are invalid.public void setStrokingColor(int g) throws java.io.IOException
g
- The gray value.java.io.IOException
- If an IO error occurs while writing to the stream.java.lang.IllegalArgumentException
- If the parameter is invalid.public void setStrokingColor(double g) throws java.io.IOException
g
- The gray value.java.io.IOException
- If an IO error occurs while writing to the stream.java.lang.IllegalArgumentException
- If the parameter is invalid.public void setNonStrokingColor(float[] components) throws java.io.IOException
components
- The components to set for the current color.java.io.IOException
- If there is an error while writing to the stream.public void setNonStrokingColor(int r, int g, int b) throws java.io.IOException
r
- The red value.g
- The green value.b
- The blue value.java.io.IOException
- If an IO error occurs while writing to the stream.java.lang.IllegalArgumentException
- If the parameters are invalid.public void setNonStrokingColor(int c, int m, int y, int k) throws java.io.IOException
c
- The cyan value.m
- The magenta value.y
- The yellow value.k
- The black value.java.io.IOException
- If an IO error occurs while writing to the stream.java.lang.IllegalArgumentException
- If the current colorspace is not
DeviceCMYK, or if the parameters are invalid.public void setNonStrokingColor(double c, double m, double y, double k) throws java.io.IOException
c
- The cyan value.m
- The magenta value.y
- The yellow value.k
- The black value.java.io.IOException
- If an IO error occurs while writing to the stream.java.lang.IllegalArgumentException
- If the current colorspace is not
DeviceCMYK, or if the parameters are invalid.public void setNonStrokingColor(int g) throws java.io.IOException
g
- The gray value.java.io.IOException
- If an IO error occurs while writing to the stream.java.lang.IllegalArgumentException
- If the current colorspace is not
DeviceGray, or if the parameter is invalid.public void setNonStrokingColor(double g) throws java.io.IOException
g
- The gray value.java.io.IOException
- If an IO error occurs while writing to the stream.java.lang.IllegalArgumentException
- If the current colorspace is not
DeviceGray, or if the parameter is invalid.public void addRect(float x, float y, float width, float height) throws java.io.IOException
x
- The lower left x coordinate.y
- The lower left y coordinate.width
- The width of the rectangle.height
- The height of the rectangle.java.io.IOException
- If there is an error while drawing on the screen.public void fillRect(float x, float y, float width, float height) throws java.io.IOException
x
- The lower left x coordinate.y
- The lower left y coordinate.width
- The width of the rectangle.height
- The height of the rectangle.java.io.IOException
- If there is an error while drawing on the screen.public void addBezier312(float x1, float y1, float x2, float y2, float x3, float y3) throws java.io.IOException
x1
- x coordinate of the point 1y1
- y coordinate of the point 1x2
- x coordinate of the point 2y2
- y coordinate of the point 2x3
- x coordinate of the point 3y3
- y coordinate of the point 3java.io.IOException
- If there is an error while adding the .public void addBezier32(float x2, float y2, float x3, float y3) throws java.io.IOException
x2
- x coordinate of the point 2y2
- y coordinate of the point 2x3
- x coordinate of the point 3y3
- y coordinate of the point 3java.io.IOException
- If there is an error while adding the .public void addBezier31(float x1, float y1, float x3, float y3) throws java.io.IOException
x1
- x coordinate of the point 1y1
- y coordinate of the point 1x3
- x coordinate of the point 3y3
- y coordinate of the point 3java.io.IOException
- If there is an error while adding the .public void moveTo(float x, float y) throws java.io.IOException
x
- The x coordinate.y
- The y coordinate.java.io.IOException
- If there is an error while adding the line.public void lineTo(float x, float y) throws java.io.IOException
x
- The x coordinate.y
- The y coordinate.java.io.IOException
- If there is an error while adding the line.public void addLine(float xStart, float yStart, float xEnd, float yEnd) throws java.io.IOException
xStart
- The start x coordinate.yStart
- The start y coordinate.xEnd
- The end x coordinate.yEnd
- The end y coordinate.java.io.IOException
- If there is an error while adding the line.public void drawLine(float xStart, float yStart, float xEnd, float yEnd) throws java.io.IOException
xStart
- The start x coordinate.yStart
- The start y coordinate.xEnd
- The end x coordinate.yEnd
- The end y coordinate.java.io.IOException
- If there is an error while drawing on the screen.public void addPolygon(float[] x, float[] y) throws java.io.IOException
x
- x coordinate of each pointsy
- y coordinate of each pointsjava.io.IOException
- If there is an error while drawing on the screen.public void drawPolygon(float[] x, float[] y) throws java.io.IOException
x
- x coordinate of each pointsy
- y coordinate of each pointsjava.io.IOException
- If there is an error while drawing on the screen.public void fillPolygon(float[] x, float[] y) throws java.io.IOException
x
- x coordinate of each pointsy
- y coordinate of each pointsjava.io.IOException
- If there is an error while drawing on the screen.public void stroke() throws java.io.IOException
java.io.IOException
- If there is an error while stroking the path.public void closeAndStroke() throws java.io.IOException
java.io.IOException
- If there is an error while closing and stroking the path.public void fill(int windingRule) throws java.io.IOException
windingRule
- the winding rule to be used for fillingjava.io.IOException
- If there is an error while filling the path.public void closeSubPath() throws java.io.IOException
java.io.IOException
- If there is an error while closing the subpath.public void clipPath(int windingRule) throws java.io.IOException
windingRule
- the winding rule to be used for clippingjava.io.IOException
- If there is an error while clipping the path.public void setLineWidth(float lineWidth) throws java.io.IOException
lineWidth
- The width which is used for drwaing.java.io.IOException
- If there is an error while drawing on the screen.public void setLineJoinStyle(int lineJoinStyle) throws java.io.IOException
lineJoinStyle
- 0 for miter join, 1 for round join, and 2 for bevel join.java.io.IOException
- If there is an error while writing to the stream.public void setLineCapStyle(int lineCapStyle) throws java.io.IOException
lineCapStyle
- 0 for butt cap, 1 for round cap, and 2 for projecting square cap.java.io.IOException
- If there is an error while writing to the stream.public void setLineDashPattern(float[] pattern, float phase) throws java.io.IOException
pattern
- The pattern arrayphase
- The phase of the patternjava.io.IOException
- If there is an error while writing to the stream.public void beginMarkedContentSequence(COSName tag) throws java.io.IOException
tag
- the tagjava.io.IOException
- if an I/O error occurspublic void beginMarkedContentSequence(COSName tag, COSName propsName) throws java.io.IOException
tag
- the tagpropsName
- the properties referencejava.io.IOException
- if an I/O error occurspublic void endMarkedContentSequence() throws java.io.IOException
java.io.IOException
- if an I/O error occurspublic void saveGraphicsState() throws java.io.IOException
java.io.IOException
- If an error occurs while writing to the stream.public void restoreGraphicsState() throws java.io.IOException
java.io.IOException
- If an error occurs while writing to the stream.public void appendRawCommands(java.lang.String commands) throws java.io.IOException
commands
- The commands to append to the stream.java.io.IOException
- If an error occurs while writing to the stream.public void appendRawCommands(byte[] commands) throws java.io.IOException
commands
- The commands to append to the stream.java.io.IOException
- If an error occurs while writing to the stream.public void appendRawCommands(int data) throws java.io.IOException
data
- Append a raw byte to the stream.java.io.IOException
- If an error occurs while writing to the stream.public void appendRawCommands(double data) throws java.io.IOException
data
- Append a formatted double value to the stream.java.io.IOException
- If an error occurs while writing to the stream.public void appendRawCommands(float data) throws java.io.IOException
data
- Append a formatted float value to the stream.java.io.IOException
- If an error occurs while writing to the stream.public void appendCOSName(COSName name) throws java.io.IOException
COSName
to the content stream.name
- the namejava.io.IOException
- If an error occurs while writing to the stream.public void close() throws java.io.IOException
close
in interface java.lang.AutoCloseable
close
in interface java.io.Closeable
java.io.IOException
- If the underlying stream has a problem being written to.