Top Description Fields Constructors Methods
org.apache.pdfbox.pdmodel

public final Class PDAppearanceContentStream

extends PDAbstractContentStream
implements Closeable
Class Inheritance
All Implemented Interfaces
java.io.Closeable, java.lang.AutoCloseable
Imports
java.io.Closeable, .IOException, .OutputStream, org.apache.pdfbox.contentstream.operator.OperatorName, org.apache.pdfbox.cos.COSArray, .COSName, org.apache.pdfbox.pdmodel.graphics.color.PDColor, org.apache.pdfbox.pdmodel.interactive.annotation.PDAppearanceStream, .PDBorderStyleDictionary

Provides the ability to write to an appearance content stream.
Author
Ben Litchfield

Field Summary

Inherited from org.apache.pdfbox.pdmodel.PDAbstractContentStream:
documentfontStackinTextModenonStrokingColorSpaceStackoutputStreamresourcesstrokingColorSpaceStack

Constructor Summary

AccessConstructor and Description
public
PDAppearanceContentStream(PDAppearanceStream
The appearance stream to write to.
appearance
)

Create a new appearance stream.

public
PDAppearanceContentStream(PDAppearanceStream
The appearance stream to write to.
appearance
,
boolean
whether the content stream is to be compressed. Set this to true when creating long content streams.
compress
)

Create a new appearance stream.

public
PDAppearanceContentStream(PDAppearanceStream
The appearance stream to add to.
appearance
,
OutputStream
The appearances output stream to write to.
outputStream
)

Create a new appearance stream.

Method Summary

Modifier and TypeMethod and Description
public void
drawShape(float
the line width of the path.
lineWidth
,
boolean
shall there be a stroking color.
hasStroke
,
boolean
shall there be a fill color.
hasFill
)

Draw a shape.

public void
setBorderLine(float
The line width.
lineWidth
,
PDBorderStyleDictionary
The border style, may be null.
bs
,
COSArray
The border array, must have at least three entries. This is only used if the border style is null.
border
)

Convenience method for annotations: sets the line with and dash style.

public void
setLineWidthOnDemand(float
the line width of the path.
lineWidth
)

Sets the line width.

public void
setNonStrokingColor(float[]
the color components dependent on the color space being used.
components
)

Set the non stroking color.

public boolean

Returns:

true if the non stroking color was set successfully
setNonStrokingColorOnDemand
(PDColor
The colorspace to write.
color
)

Set the non stroking color.

public void
setStrokingColor(float[]
the color components dependent on the color space being used.
components
)

Set the stroking color.

public boolean

Returns:

true if the stroking color was set successfully
setStrokingColorOnDemand
(PDColor
The colorspace to write.
color
)

Set the stroking color.

Inherited from org.apache.pdfbox.pdmodel.PDAbstractContentStream:
addCommentaddRectbeginMarkedContentbeginMarkedContentbeginMarkedContentbeginTextclipclipEvenOddclosecloseAndFillAndStrokecloseAndFillAndStrokeEvenOddcloseAndStrokeclosePathcurveTocurveTo1curveTo2drawFormdrawImagedrawImagedrawImagedrawImagedrawImageendMarkedContentendTextfillfillAndStrokefillAndStrokeEvenOddfillEvenOddgetNameisOutside255IntervallineTomoveTonewLinenewLineAtOffsetrestoreGraphicsStatesaveGraphicsStatesetCharacterSpacingsetFontsetGraphicsStateParameterssetHorizontalScalingsetLeadingsetLineCapStylesetLineDashPatternsetLineJoinStylesetLineWidthsetMaximumFractionDigitssetMiterLimitsetNonStrokingColorsetNonStrokingColorsetNonStrokingColorsetNonStrokingColorsetNonStrokingColorsetNonStrokingColorSpaceStacksetRenderingModesetStrokingColorsetStrokingColorsetStrokingColorsetStrokingColorsetStrokingColorsetStrokingColorSpaceStacksetTextMatrixsetTextRisesetWordSpacingshadingFillshowTextshowTextInternalshowTextWithPositioningstroketransformwritewriteByteswriteLinewriteOperandwriteOperandwriteOperandwriteOperator

Constructor Detail

PDAppearanceContentStreamback to summary
public PDAppearanceContentStream(PDAppearanceStream appearance) throws IOException

Create a new appearance stream.

Parameters
appearance:PDAppearanceStream

The appearance stream to write to.

Exceptions
IOException:
If there is an error writing to the content stream.
PDAppearanceContentStreamback to summary
public PDAppearanceContentStream(PDAppearanceStream appearance, boolean compress) throws IOException

Create a new appearance stream.

Parameters
appearance:PDAppearanceStream

The appearance stream to write to.

compress:boolean

whether the content stream is to be compressed. Set this to true when creating long content streams.

Exceptions
IOException:
If there is an error writing to the content stream.
PDAppearanceContentStreamback to summary
public PDAppearanceContentStream(PDAppearanceStream appearance, OutputStream outputStream)

Create a new appearance stream.

Parameters
appearance:PDAppearanceStream

The appearance stream to add to.

outputStream:OutputStream

The appearances output stream to write to.

Method Detail

drawShapeback to summary
public void drawShape(float lineWidth, boolean hasStroke, boolean hasFill) throws IOException

Draw 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:float

the line width of the path.

hasStroke:boolean

shall there be a stroking color.

hasFill:boolean

shall there be a fill color.

Exceptions
IOException:
If there is an error writing to the content stream.
setBorderLineback to summary
public void setBorderLine(float lineWidth, PDBorderStyleDictionary bs, COSArray border) throws IOException

Convenience method for annotations: sets the line with and dash style.

Parameters
lineWidth:float

The line width.

bs:PDBorderStyleDictionary

The border style, may be null.

border:COSArray

The border array, must have at least three entries. This is only used if the border style is null.

Exceptions
IOException:
If there is an error writing to the content stream.
setLineWidthOnDemandback to summary
public void setLineWidthOnDemand(float lineWidth) throws IOException

Sets the line width. The command is only emitted if the lineWidth is different to 1.

Parameters
lineWidth:float

the line width of the path.

Exceptions
IOException:
If there is an error writing to the content stream.
See Also
PDAbstractContentStream#setLineWidth(float)
setNonStrokingColorback to summary
public void setNonStrokingColor(float[] components) throws IOException

Set the non stroking color.

Parameters
components:float[]

the color components dependent on the color space being used.

Exceptions
IOException:
If there is an error writing to the content stream.
See Also
PDAbstractContentStream#setNonStrokingColor(java.awt.Color)
setNonStrokingColorOnDemandback to summary
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:PDColor

The colorspace to write.

Returns:boolean

true if the non stroking color was set successfully

Exceptions
IOException:
If there is an error writing to the content stream.
See Also
PDAbstractContentStream#setNonStrokingColor(PDColor)
setStrokingColorback to summary
public void setStrokingColor(float[] components) throws IOException

Set the stroking color.

Parameters
components:float[]

the color components dependent on the color space being used.

Exceptions
IOException:
If there is an error writing to the content stream.
See Also
PDAbstractContentStream#setStrokingColor(java.awt.Color)
setStrokingColorOnDemandback to summary
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:PDColor

The colorspace to write.

Returns:boolean

true if the stroking color was set successfully

Exceptions
IOException:
If there is an error writing to the content stream.
See Also
PDAbstractContentStream#setStrokingColor(PDColor)