Package com.tom_roush.pdfbox.pdmodel
Class PDAppearanceContentStream
- java.lang.Object
-
- com.tom_roush.pdfbox.pdmodel.PDAppearanceContentStream
-
- All Implemented Interfaces:
Closeable,AutoCloseable
public final class PDAppearanceContentStream extends Object implements Closeable
Provides the ability to write to an appearance content stream.
-
-
Field Summary
Fields Modifier and Type Field Description protected PDDocumentdocumentprotected Deque<PDFont>fontStackprotected booleaninTextModeprotected Deque<PDColorSpace>nonStrokingColorSpaceStackprotected OutputStreamoutputStreamprotected PDResourcesresourcesprotected Deque<PDColorSpace>strokingColorSpaceStack
-
Constructor Summary
Constructors Constructor Description PDAppearanceContentStream(PDAppearanceStream appearance)Create a new appearance stream.PDAppearanceContentStream(PDAppearanceStream appearance, boolean compress)Create a new appearance stream.PDAppearanceContentStream(PDAppearanceStream appearance, OutputStream outputStream)Create a new appearance stream.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddComment(String comment)Write a comment line.voidaddRect(float x, float y, float width, float height)Add a rectangle to the current path.voidbeginMarkedContent(COSName tag)Begin a marked content sequence.voidbeginMarkedContent(COSName tag, PDPropertyList propertyList)Begin a marked content sequence with a reference to an entry in the page resources' Properties dictionary.voidbeginText()Begin some text operations.voidclip()Intersects the current clipping path with the current path, using the nonzero rule.voidclipEvenOdd()Intersects the current clipping path with the current path, using the even-odd rule.voidclose()Close the content stream.voidcloseAndFillAndStroke()Close, fill, and then stroke the path, using the nonzero winding number rule to determine the region to fill.voidcloseAndFillAndStrokeEvenOdd()Close, fill, and then stroke the path, using the even-odd rule to determine the region to fill.voidcloseAndStroke()Close and stroke the path.voidclosePath()Closes the current subpath.voidcurveTo(float x1, float y1, float x2, float y2, float x3, float y3)Append a cubic Bézier curve to the current path.voidcurveTo1(float x1, float y1, float x3, float y3)Append a cubic Bézier curve to the current path.voidcurveTo2(float x2, float y2, float x3, float y3)Append a cubic Bézier curve to the current path.voiddrawForm(PDFormXObject form)Draws the given Form XObject at the current location.voiddrawImage(PDImageXObject image, float x, float y)Draw an image at the x,y coordinates, with the default size of the image.voiddrawImage(PDImageXObject image, float x, float y, float width, float height)Draw an image at the x,y coordinates, with the given size.voiddrawImage(PDImageXObject image, Matrix matrix)Draw an image at the origin with the given transformation matrix.voiddrawImage(PDInlineImage inlineImage, float x, float y)Draw an inline image at the x,y coordinates, with the default size of the image.voiddrawImage(PDInlineImage inlineImage, float x, float y, float width, float height)Draw an inline image at the x,y coordinates and a certain width and height.voiddrawShape(float lineWidth, boolean hasStroke, boolean hasFill)Draw a shape.voidendMarkedContent()End a marked content sequence.voidendText()End some text operations.voidfill()Fills the path using the nonzero winding number rule.voidfillAndStroke()Fill and then stroke the path, using the nonzero winding number rule to determine the region to fill.voidfillAndStrokeEvenOdd()Fill and then stroke the path, using the even-odd rule to determine the region to fill.voidfillEvenOdd()Fills the path using the even-odd winding rule.protected COSNamegetName(PDColorSpace colorSpace)protected booleanisOutside255Interval(int val)voidlineTo(float x, float y)Draw a line from the current position to the given coordinates.voidmoveTo(float x, float y)Move the current position to the given coordinates.voidnewLine()Move to the start of the next line of text.voidnewLineAtOffset(float tx, float ty)The Td operator.voidrestoreGraphicsState()Q operator.voidsaveGraphicsState()q operator.voidsetBorderLine(float lineWidth, PDBorderStyleDictionary bs, COSArray border)Convenience method for annotations: sets the line with and dash style.voidsetCharacterSpacing(float spacing)Set the character spacing.voidsetFont(PDFont font, float fontSize)Set the font and font size to draw text with.voidsetGraphicsStateParameters(PDExtendedGraphicsState state)Set an extended graphics state.voidsetHorizontalScaling(float scale)Set the horizontal scaling to scale / 100.voidsetLeading(float leading)Sets the text leading.voidsetLineCapStyle(int lineCapStyle)Set the line cap style.voidsetLineDashPattern(float[] pattern, float phase)Set the line dash pattern.voidsetLineJoinStyle(int lineJoinStyle)Set the line join style.voidsetLineWidth(float lineWidth)Set line width to the given value.voidsetLineWidthOnDemand(float lineWidth)Sets the line width.protected voidsetMaximumFractionDigits(int fractionDigitsNumber)Sets the maximum number of digits allowed for fractional numbers.voidsetMiterLimit(float miterLimit)Set the miter limit.voidsetNonStrokingColor(float g)Set the non-stroking color in the DeviceGray color space.voidsetNonStrokingColor(float[] components)Set the non stroking color.voidsetNonStrokingColor(float r, float g, float b)Set the non-stroking color in the DeviceRGB color space.voidsetNonStrokingColor(float c, float m, float y, float k)Set the non-stroking color in the DeviceCMYK color space.voidsetNonStrokingColor(int g)Deprecated.voidsetNonStrokingColor(int r, int g, int b)Deprecated.voidsetNonStrokingColor(int c, int m, int y, int k)Set the non-stroking color in the DeviceCMYK color space.voidsetNonStrokingColor(AWTColor color)Set the non-stroking color using an AWT color.voidsetNonStrokingColor(PDColor color)Sets the non-stroking color and, if necessary, the non-stroking color space.booleansetNonStrokingColorOnDemand(PDColor color)Set the non stroking color.protected voidsetNonStrokingColorSpaceStack(PDColorSpace colorSpace)voidsetRenderingMode(RenderingMode rm)Set the text rendering mode.voidsetStrokingColor(float g)Set the stroking color in the DeviceGray color space.voidsetStrokingColor(float[] components)Set the stroking color.voidsetStrokingColor(float r, float g, float b)Set the stroking color in the DeviceRGB color space.voidsetStrokingColor(float c, float m, float y, float k)Set the stroking color in the DeviceCMYK color space.voidsetStrokingColor(int r, int g, int b)Deprecated.voidsetStrokingColor(AWTColor color)Set the stroking color using an AWT color.voidsetStrokingColor(PDColor color)Sets the stroking color and, if necessary, the stroking color space.booleansetStrokingColorOnDemand(PDColor color)Set the stroking color.protected voidsetStrokingColorSpaceStack(PDColorSpace colorSpace)voidsetTextMatrix(Matrix matrix)The Tm operator.voidsetTextRise(float rise)Set the text rise value, i.e.voidsetWordSpacing(float spacing)Set the word spacing.voidshadingFill(PDShading shading)Fills the clipping area with the given shading.voidshowText(String text)Shows the given text at the location specified by the current text matrix.protected voidshowTextInternal(String text)Outputs a string using the correct encoding and subsetting as required.voidshowTextWithPositioning(Object[] textWithPositioningArray)Shows the given text at the location specified by the current text matrix with the given interspersed positioning.voidstroke()Stroke the path.voidtransform(Matrix matrix)The cm operator.protected voidwrite(byte[] data)Writes a byte[] to the content stream.protected voidwrite(String text)Writes a string to the content stream as ASCII.protected voidwriteBytes(byte[] data)Writes binary data to the content stream.protected voidwriteLine()Writes a newline to the content stream as ASCII.protected voidwriteOperand(float real)Writes a real number to the content stream.protected voidwriteOperand(int integer)Writes an integer number to the content stream.protected voidwriteOperand(COSName name)Writes a COSName to the content stream.protected voidwriteOperator(String text)Writes a string to the content stream as ASCII.
-
-
-
Field Detail
-
document
protected final PDDocument document
-
outputStream
protected final OutputStream outputStream
-
resources
protected final PDResources resources
-
inTextMode
protected boolean inTextMode
-
nonStrokingColorSpaceStack
protected final Deque<PDColorSpace> nonStrokingColorSpaceStack
-
strokingColorSpaceStack
protected final Deque<PDColorSpace> strokingColorSpaceStack
-
-
Constructor Detail
-
PDAppearanceContentStream
public PDAppearanceContentStream(PDAppearanceStream appearance) throws IOException
Create a new appearance stream.- Parameters:
appearance- The appearance stream to write to.- Throws:
IOException- If there is an error writing to the content stream.
-
PDAppearanceContentStream
public PDAppearanceContentStream(PDAppearanceStream appearance, boolean compress) throws IOException
Create a new appearance stream.- Parameters:
appearance- The appearance stream to write to.compress- whether the content stream is to be compressed. Set this to true when creating long content streams.- Throws:
IOException- If there is an error writing to the content stream.
-
PDAppearanceContentStream
public PDAppearanceContentStream(PDAppearanceStream appearance, OutputStream outputStream)
Create a new appearance stream.- Parameters:
appearance- The appearance stream to add to.outputStream- The appearances output stream to write to.
-
-
Method Detail
-
setStrokingColorOnDemand
public boolean setStrokingColorOnDemand(PDColor color) throws IOException
Set the stroking color.The command is only emitted if the color is not null and the number of components is > 0.
- Parameters:
color- The colorspace to write.- Throws:
IOException- If there is an error writing to the content stream.- See Also:
PDAbstractContentStream.setStrokingColor(PDColor)
-
setStrokingColor
public void setStrokingColor(float[] components) throws IOExceptionSet the stroking color.- Parameters:
components- the color components dependent on the color space being used.- Throws:
IOException- If there is an error writing to the content stream.- See Also:
PDAbstractContentStream.setStrokingColor(com.tom_roush.harmony.awt.AWTColor)
-
setNonStrokingColorOnDemand
public boolean setNonStrokingColorOnDemand(PDColor color) throws IOException
Set the non stroking color.The command is only emitted if the color is not null and the number of components is > 0.
- Parameters:
color- The colorspace to write.- Throws:
IOException- If there is an error writing to the content stream.- See Also:
PDAbstractContentStream.setNonStrokingColor(PDColor)
-
setNonStrokingColor
public void setNonStrokingColor(float[] components) throws IOExceptionSet the non stroking color.- Parameters:
components- the color components dependent on the color space being used.- Throws:
IOException- If there is an error writing to the content stream.- See Also:
PDAbstractContentStream.setNonStrokingColor(com.tom_roush.harmony.awt.AWTColor)
-
setBorderLine
public void setBorderLine(float lineWidth, PDBorderStyleDictionary bs, COSArray border) throws IOExceptionConvenience method for annotations: sets the line with and dash style.- Parameters:
lineWidth- The line width.bs- The border style, may be null.border- The border array, must have at least three entries. This is only used if the border style is null.- Throws:
IOException- If there is an error writing to the content stream.
-
setLineWidthOnDemand
public void setLineWidthOnDemand(float lineWidth) throws IOExceptionSets the line width. The command is only emitted if the lineWidth is different to 1.- Parameters:
lineWidth- the line width of the path.- Throws:
IOException- If there is an error writing to the content stream.- See Also:
PDAbstractContentStream.setLineWidth(float)
-
drawShape
public void drawShape(float lineWidth, boolean hasStroke, boolean hasFill) throws IOExceptionDraw a shape.Dependent on the lineWidth and whether or not there is a background to be generated there are different commands to be used for draw a shape.
- Parameters:
lineWidth- the line width of the path.hasStroke- shall there be a stroking color.hasFill- shall there be a fill color.- Throws:
IOException- If there is an error writing to the content stream.
-
setMaximumFractionDigits
protected void setMaximumFractionDigits(int fractionDigitsNumber)
Sets the maximum number of digits allowed for fractional numbers.- Parameters:
fractionDigitsNumber-- See Also:
NumberFormat.setMaximumFractionDigits(int)
-
beginText
public void beginText() throws IOExceptionBegin some text operations.- Throws:
IOException- If there is an error writing to the stream or if you attempt to nest beginText calls.IllegalStateException- If the method was not allowed to be called at this time.
-
endText
public void endText() throws IOExceptionEnd some text operations.- Throws:
IOException- If there is an error writing to the stream or if you attempt to nest endText calls.IllegalStateException- If the method was not allowed to be called at this time.
-
setFont
public void setFont(PDFont font, float fontSize) throws IOException
Set the font and font size to draw text with.- Parameters:
font- The font to use.fontSize- The font size to draw the text.- Throws:
IOException- If there is an error writing the font information.
-
showTextWithPositioning
public void showTextWithPositioning(Object[] textWithPositioningArray) throws IOException
Shows the given text at the location specified by the current text matrix with the given interspersed positioning. This allows the user to efficiently position each glyph or sequence of glyphs.- Parameters:
textWithPositioningArray- An array consisting of String and Float types. Each String is output to the page using the current text matrix. Using the default coordinate system, each interspersed number adjusts the current text matrix by translating to the left or down for horizontal and vertical text respectively. The number is expressed in thousands of a text space unit, and may be negative.- Throws:
IOException- if an io exception occurs.
-
showText
public void showText(String text) throws IOException
Shows the given text at the location specified by the current text matrix.- Parameters:
text- The Unicode text to show.- Throws:
IOException- If an io exception occurs.IllegalArgumentException- if a character isn't supported by the current font
-
showTextInternal
protected void showTextInternal(String text) throws IOException
Outputs a string using the correct encoding and subsetting as required.- Parameters:
text- The Unicode text to show.- Throws:
IOException- If an io exception occurs.
-
setLeading
public void setLeading(float leading) throws IOExceptionSets the text leading.- Parameters:
leading- The leading in unscaled text units.- Throws:
IOException- If there is an error writing to the stream.
-
newLine
public void newLine() throws IOExceptionMove to the start of the next line of text. Requires the leading (seesetLeading(float)) to have been set.- Throws:
IOException- If there is an error writing to the stream.
-
newLineAtOffset
public void newLineAtOffset(float tx, float ty) throws IOExceptionThe Td operator. Move to the start of the next line, offset from the start of the current line by (tx, ty).- Parameters:
tx- The x translation.ty- The y translation.- Throws:
IOException- If there is an error writing to the stream.IllegalStateException- If the method was not allowed to be called at this time.
-
setTextMatrix
public void setTextMatrix(Matrix matrix) throws IOException
The Tm operator. Sets the text matrix to the given values. A current text matrix will be replaced with the new one.- Parameters:
matrix- the transformation matrix- Throws:
IOException- If there is an error writing to the stream.IllegalStateException- If the method was not allowed to be called at this time.
-
drawImage
public void drawImage(PDImageXObject image, float x, float y) throws IOException
Draw an image at the x,y coordinates, with the default size of the image.- Parameters:
image- The image to draw.x- The x-coordinate to draw the image.y- The y-coordinate to draw the image.- Throws:
IOException- If there is an error writing to the stream.
-
drawImage
public void drawImage(PDImageXObject image, float x, float y, float width, float height) throws IOException
Draw an image at the x,y coordinates, with the given size.- Parameters:
image- The image to draw.x- The x-coordinate to draw the image.y- The y-coordinate to draw the image.width- The width to draw the image.height- The height to draw the image.- Throws:
IOException- If there is an error writing to the stream.IllegalStateException- If the method was called within a text block.
-
drawImage
public void drawImage(PDImageXObject image, Matrix matrix) throws IOException
Draw an image at the origin with the given transformation matrix.- Parameters:
image- The image to draw.matrix- The transformation matrix to apply to the image.- Throws:
IOException- If there is an error writing to the stream.IllegalStateException- If the method was called within a text block.
-
drawImage
public void drawImage(PDInlineImage inlineImage, float x, float y) throws IOException
Draw an inline image at the x,y coordinates, with the default size of the image.- Parameters:
inlineImage- The inline image to draw.x- The x-coordinate to draw the inline image.y- The y-coordinate to draw the inline image.- Throws:
IOException- If there is an error writing to the stream.
-
drawImage
public void drawImage(PDInlineImage inlineImage, float x, float y, float width, float height) throws IOException
Draw an inline image at the x,y coordinates and a certain width and height.- Parameters:
inlineImage- The inline image to draw.x- The x-coordinate to draw the inline image.y- The y-coordinate to draw the inline image.width- The width of the inline image to draw.height- The height of the inline image to draw.- Throws:
IOException- If there is an error writing to the stream.IllegalStateException- If the method was called within a text block.
-
drawForm
public void drawForm(PDFormXObject form) throws IOException
Draws the given Form XObject at the current location.- Parameters:
form- Form XObject- Throws:
IOException- if the content stream could not be writtenIllegalStateException- If the method was called within a text block.
-
transform
public void transform(Matrix matrix) throws IOException
The cm operator. Concatenates the given matrix with the current transformation matrix (CTM), which maps user space coordinates used within a PDF content stream into output device coordinates. More details on coordinates can be found in the PDF 32000 specification, 8.3.2 Coordinate Spaces.- Parameters:
matrix- the transformation matrix- Throws:
IOException- If there is an error writing to the stream.
-
saveGraphicsState
public void saveGraphicsState() throws IOExceptionq operator. Saves the current graphics state.- Throws:
IOException- If an error occurs while writing to the stream.
-
restoreGraphicsState
public void restoreGraphicsState() throws IOExceptionQ operator. Restores the current graphics state.- Throws:
IOException- If an error occurs while writing to the stream.
-
getName
protected COSName getName(PDColorSpace colorSpace)
-
setStrokingColor
public void setStrokingColor(PDColor color) throws IOException
Sets the stroking color and, if necessary, the stroking color space.- Parameters:
color- Color in a specific color space.- Throws:
IOException- If an IO error occurs while writing to the stream.
-
setStrokingColor
public void setStrokingColor(AWTColor color) throws IOException
Set the stroking color using an AWT color. Conversion uses the default sRGB color space.- Parameters:
color- The color to set.- Throws:
IOException- If an IO error occurs while writing to the stream.
-
setStrokingColor
public void setStrokingColor(float r, float g, float b) throws IOExceptionSet the stroking color in the DeviceRGB color space. Range is 0..1.- Parameters:
r- The red valueg- The green value.b- The blue value.- Throws:
IOException- If an IO error occurs while writing to the stream.IllegalArgumentException- If the parameters are invalid.
-
setStrokingColor
@Deprecated public void setStrokingColor(int r, int g, int b) throws IOException
Deprecated.Set the stroking color in the DeviceRGB color space. Range is 0..255.- Parameters:
r- The red valueg- The green value.b- The blue value.- Throws:
IOException- If an IO error occurs while writing to the stream.IllegalArgumentException- If the parameters are invalid.
-
setStrokingColor
public void setStrokingColor(float c, float m, float y, float k) throws IOExceptionSet the stroking color in the DeviceCMYK color space. Range is 0..1- Parameters:
c- The cyan value.m- The magenta value.y- The yellow value.k- The black value.- Throws:
IOException- If an IO error occurs while writing to the stream.IllegalArgumentException- If the parameters are invalid.
-
setStrokingColor
public void setStrokingColor(float g) throws IOExceptionSet the stroking color in the DeviceGray color space. Range is 0..1.- Parameters:
g- The gray value.- Throws:
IOException- If an IO error occurs while writing to the stream.IllegalArgumentException- If the parameter is invalid.
-
setNonStrokingColor
public void setNonStrokingColor(PDColor color) throws IOException
Sets the non-stroking color and, if necessary, the non-stroking color space.- Parameters:
color- Color in a specific color space.- Throws:
IOException- If an IO error occurs while writing to the stream.
-
setNonStrokingColor
public void setNonStrokingColor(AWTColor color) throws IOException
Set the non-stroking color using an AWT color. Conversion uses the default sRGB color space.- Parameters:
color- The color to set.- Throws:
IOException- If an IO error occurs while writing to the stream.
-
setNonStrokingColor
public void setNonStrokingColor(float r, float g, float b) throws IOExceptionSet the non-stroking color in the DeviceRGB color space. Range is 0..255.- Parameters:
r- The red value.g- The green value.b- The blue value.- Throws:
IOException- If an IO error occurs while writing to the stream.IllegalArgumentException- If the parameters are invalid.
-
setNonStrokingColor
@Deprecated public void setNonStrokingColor(int r, int g, int b) throws IOException
Deprecated.Set the non stroking color in the DeviceRGB color space. Range is 0..255.- Parameters:
r- The red valueg- The green value.b- The blue value.- Throws:
IOException- If an IO error occurs while writing to the stream.IllegalArgumentException- If the parameters are invalid.
-
setNonStrokingColor
public void setNonStrokingColor(int c, int m, int y, int k) throws IOExceptionSet the non-stroking color in the DeviceCMYK color space. Range is 0..255.- Parameters:
c- The cyan value.m- The magenta value.y- The yellow value.k- The black value.- Throws:
IOException- If an IO error occurs while writing to the stream.IllegalArgumentException- If the parameters are invalid.
-
setNonStrokingColor
public void setNonStrokingColor(float c, float m, float y, float k) throws IOExceptionSet the non-stroking color in the DeviceCMYK color space. Range is 0..1.- Parameters:
c- The cyan value.m- The magenta value.y- The yellow value.k- The black value.- Throws:
IOException- If an IO error occurs while writing to the stream.
-
setNonStrokingColor
public void setNonStrokingColor(int g) throws IOExceptionDeprecated.Set the non-stroking color in the DeviceGray color space. Range is 0..255.- Parameters:
g- The gray value.- Throws:
IOException- If an IO error occurs while writing to the stream.IllegalArgumentException- If the parameter is invalid.
-
setNonStrokingColor
public void setNonStrokingColor(float g) throws IOExceptionSet the non-stroking color in the DeviceGray color space. Range is 0..1.- Parameters:
g- The gray value.- Throws:
IOException- If an IO error occurs while writing to the stream.IllegalArgumentException- If the parameter is invalid.
-
addRect
public void addRect(float x, float y, float width, float height) throws IOExceptionAdd a rectangle to the current path.- Parameters:
x- The lower left x coordinate.y- The lower left y coordinate.width- The width of the rectangle.height- The height of the rectangle.- Throws:
IOException- If the content stream could not be written.IllegalStateException- If the method was called within a text block.
-
curveTo
public void curveTo(float x1, float y1, float x2, float y2, float x3, float y3) throws IOExceptionAppend a cubic Bézier curve to the current path. The curve extends from the current point to the point (x3, y3), using (x1, y1) and (x2, y2) as the Bézier control points.- Parameters:
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 3- Throws:
IOException- If the content stream could not be written.IllegalStateException- If the method was called within a text block.
-
curveTo2
public void curveTo2(float x2, float y2, float x3, float y3) throws IOExceptionAppend a cubic Bézier curve to the current path. The curve extends from the current point to the point (x3, y3), using the current point and (x2, y2) as the Bézier control points.- Parameters:
x2- x coordinate of the point 2y2- y coordinate of the point 2x3- x coordinate of the point 3y3- y coordinate of the point 3- Throws:
IllegalStateException- If the method was called within a text block.IOException- If the content stream could not be written.
-
curveTo1
public void curveTo1(float x1, float y1, float x3, float y3) throws IOExceptionAppend a cubic Bézier curve to the current path. The curve extends from the current point to the point (x3, y3), using (x1, y1) and (x3, y3) as the Bézier control points.- Parameters:
x1- x coordinate of the point 1y1- y coordinate of the point 1x3- x coordinate of the point 3y3- y coordinate of the point 3- Throws:
IOException- If the content stream could not be written.IllegalStateException- If the method was called within a text block.
-
moveTo
public void moveTo(float x, float y) throws IOExceptionMove the current position to the given coordinates.- Parameters:
x- The x coordinate.y- The y coordinate.- Throws:
IOException- If the content stream could not be written.IllegalStateException- If the method was called within a text block.
-
lineTo
public void lineTo(float x, float y) throws IOExceptionDraw a line from the current position to the given coordinates.- Parameters:
x- The x coordinate.y- The y coordinate.- Throws:
IOException- If the content stream could not be written.IllegalStateException- If the method was called within a text block.
-
stroke
public void stroke() throws IOExceptionStroke the path.- Throws:
IOException- If the content stream could not be writtenIllegalStateException- If the method was called within a text block.
-
closeAndStroke
public void closeAndStroke() throws IOExceptionClose and stroke the path.- Throws:
IOException- If the content stream could not be writtenIllegalStateException- If the method was called within a text block.
-
fill
public void fill() throws IOExceptionFills the path using the nonzero winding number rule.- Throws:
IOException- If the content stream could not be writtenIllegalStateException- If the method was called within a text block.
-
fillEvenOdd
public void fillEvenOdd() throws IOExceptionFills the path using the even-odd winding rule.- Throws:
IOException- If the content stream could not be writtenIllegalStateException- If the method was called within a text block.
-
fillAndStroke
public void fillAndStroke() throws IOExceptionFill and then stroke the path, using the nonzero winding number rule to determine the region to fill. This shall produce the same result as constructing two identical path objects, painting the first withfill()and the second withstroke().- Throws:
IOException- If the content stream could not be writtenIllegalStateException- If the method was called within a text block.
-
fillAndStrokeEvenOdd
public void fillAndStrokeEvenOdd() throws IOExceptionFill and then stroke the path, using the even-odd rule to determine the region to fill. This shall produce the same result as constructing two identical path objects, painting the first withfillEvenOdd()and the second withstroke().- Throws:
IOException- If the content stream could not be writtenIllegalStateException- If the method was called within a text block.
-
closeAndFillAndStroke
public void closeAndFillAndStroke() throws IOExceptionClose, fill, and then stroke the path, using the nonzero winding number rule to determine the region to fill. This shall have the same effect as the sequenceclosePath()and thenfillAndStroke().- Throws:
IOException- If the content stream could not be writtenIllegalStateException- If the method was called within a text block.
-
closeAndFillAndStrokeEvenOdd
public void closeAndFillAndStrokeEvenOdd() throws IOExceptionClose, fill, and then stroke the path, using the even-odd rule to determine the region to fill. This shall have the same effect as the sequenceclosePath()and thenfillAndStrokeEvenOdd().- Throws:
IOException- If the content stream could not be writtenIllegalStateException- If the method was called within a text block.
-
shadingFill
public void shadingFill(PDShading shading) throws IOException
Fills the clipping area with the given shading.- Parameters:
shading- Shading resource- Throws:
IOException- If the content stream could not be writtenIllegalStateException- If the method was called within a text block.
-
closePath
public void closePath() throws IOExceptionCloses the current subpath.- Throws:
IOException- If the content stream could not be writtenIllegalStateException- If the method was called within a text block.
-
clip
public void clip() throws IOExceptionIntersects the current clipping path with the current path, using the nonzero rule.- Throws:
IOException- If the content stream could not be writtenIllegalStateException- If the method was called within a text block.
-
clipEvenOdd
public void clipEvenOdd() throws IOExceptionIntersects the current clipping path with the current path, using the even-odd rule.- Throws:
IOException- If the content stream could not be writtenIllegalStateException- If the method was called within a text block.
-
setLineWidth
public void setLineWidth(float lineWidth) throws IOExceptionSet line width to the given value.- Parameters:
lineWidth- The width which is used for drawing.- Throws:
IOException- If the content stream could not be written
-
setLineJoinStyle
public void setLineJoinStyle(int lineJoinStyle) throws IOExceptionSet the line join style.- Parameters:
lineJoinStyle- 0 for miter join, 1 for round join, and 2 for bevel join.- Throws:
IOException- If the content stream could not be written.IllegalArgumentException- If the parameter is not a valid line join style.
-
setLineCapStyle
public void setLineCapStyle(int lineCapStyle) throws IOExceptionSet the line cap style.- Parameters:
lineCapStyle- 0 for butt cap, 1 for round cap, and 2 for projecting square cap.- Throws:
IOException- If the content stream could not be written.IllegalArgumentException- If the parameter is not a valid line cap style.
-
setLineDashPattern
public void setLineDashPattern(float[] pattern, float phase) throws IOExceptionSet the line dash pattern.- Parameters:
pattern- The pattern arrayphase- The phase of the pattern- Throws:
IOException- If the content stream could not be written.
-
setMiterLimit
public void setMiterLimit(float miterLimit) throws IOExceptionSet the miter limit.- Parameters:
miterLimit- the new miter limit.- Throws:
IOException- If the content stream could not be written.IllegalArgumentException- If the parameter is ≤ 0.
-
beginMarkedContent
public void beginMarkedContent(COSName tag) throws IOException
Begin a marked content sequence.- Parameters:
tag- the tag- Throws:
IOException- If the content stream could not be written
-
beginMarkedContent
public void beginMarkedContent(COSName tag, PDPropertyList propertyList) throws IOException
Begin a marked content sequence with a reference to an entry in the page resources' Properties dictionary.- Parameters:
tag- the tagpropertyList- property list- Throws:
IOException- If the content stream could not be written
-
endMarkedContent
public void endMarkedContent() throws IOExceptionEnd a marked content sequence.- Throws:
IOException- If the content stream could not be written
-
setGraphicsStateParameters
public void setGraphicsStateParameters(PDExtendedGraphicsState state) throws IOException
Set an extended graphics state.- Parameters:
state- The extended graphics state.- Throws:
IOException- If the content stream could not be written.
-
addComment
public void addComment(String comment) throws IOException
Write a comment line.- Parameters:
comment-- Throws:
IOException- If the content stream could not be written.IllegalArgumentException- If the comment contains a newline. This is not allowed, because the next line could be ordinary PDF content.
-
writeOperand
protected void writeOperand(float real) throws IOExceptionWrites a real number to the content stream.- Parameters:
real-- Throws:
IOExceptionIllegalArgumentException- if the parameter is not a finite number
-
writeOperand
protected void writeOperand(int integer) throws IOExceptionWrites an integer number to the content stream.- Parameters:
integer-- Throws:
IOException
-
writeOperand
protected void writeOperand(COSName name) throws IOException
Writes a COSName to the content stream.- Parameters:
name-- Throws:
IOException
-
writeOperator
protected void writeOperator(String text) throws IOException
Writes a string to the content stream as ASCII.- Parameters:
text-- Throws:
IOException
-
write
protected void write(String text) throws IOException
Writes a string to the content stream as ASCII.- Parameters:
text-- Throws:
IOException
-
write
protected void write(byte[] data) throws IOExceptionWrites a byte[] to the content stream.- Parameters:
data-- Throws:
IOException
-
writeLine
protected void writeLine() throws IOExceptionWrites a newline to the content stream as ASCII.- Throws:
IOException
-
writeBytes
protected void writeBytes(byte[] data) throws IOExceptionWrites binary data to the content stream.- Parameters:
data-- Throws:
IOException
-
close
public void close() throws IOExceptionClose the content stream. This must be called when you are done with this object.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException- If the underlying stream has a problem being written to.
-
isOutside255Interval
protected boolean isOutside255Interval(int val)
-
setStrokingColorSpaceStack
protected void setStrokingColorSpaceStack(PDColorSpace colorSpace)
-
setNonStrokingColorSpaceStack
protected void setNonStrokingColorSpaceStack(PDColorSpace colorSpace)
-
setCharacterSpacing
public void setCharacterSpacing(float spacing) throws IOExceptionSet the character spacing. The value shall be added to the horizontal or vertical component of the glyph's displacement, depending on the writing mode.- Parameters:
spacing- character spacing- Throws:
IOException- If the content stream could not be written.
-
setWordSpacing
public void setWordSpacing(float spacing) throws IOExceptionSet the word spacing. The value shall be added to the horizontal or vertical component of the ASCII SPACE character, depending on the writing mode.This will have an effect only with Type1 and TrueType fonts, not with Type0 fonts. The PDF specification tells why: "Word spacing shall be applied to every occurrence of the single-byte character code 32 in a string when using a simple font or a composite font that defines code 32 as a single-byte code. It shall not apply to occurrences of the byte value 32 in multiple-byte codes."
- Parameters:
spacing- word spacing- Throws:
IOException- If the content stream could not be written.
-
setHorizontalScaling
public void setHorizontalScaling(float scale) throws IOExceptionSet the horizontal scaling to scale / 100.- Parameters:
scale- number specifying the percentage of the normal width. Default value: 100 (normal width).- Throws:
IOException- If the content stream could not be written.
-
setRenderingMode
public void setRenderingMode(RenderingMode rm) throws IOException
Set the text rendering mode. This determines whether showing text shall cause glyph outlines to be stroked, filled, used as a clipping boundary, or some combination of the three.- Parameters:
rm- The text rendering mode.- Throws:
IOException- If the content stream could not be written.
-
setTextRise
public void setTextRise(float rise) throws IOExceptionSet the text rise value, i.e. move the baseline up or down. This is useful for drawing superscripts or subscripts.- Parameters:
rise- Specifies the distance, in unscaled text space units, to move the baseline up or down from its default location. 0 restores the default location.- Throws:
IOException
-
-