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

pack-priv abstract Class PDAbstractContentStream

extends Object
implements Closeable
Class Inheritance
All Implemented Interfaces
java.io.Closeable, java.lang.AutoCloseable
Known Direct Subclasses
org.apache.pdfbox.pdmodel.PDAppearanceContentStream, org.apache.pdfbox.pdmodel.PDFormContentStream, org.apache.pdfbox.pdmodel.PDPageContentStream, org.apache.pdfbox.pdmodel.PDPatternContentStream
Imports
java.awt.Color, java.awt.geom.AffineTransform, java.io.ByteArrayOutputStream, .Closeable, .IOException, .OutputStream, java.nio.charset.StandardCharsets, java.text.NumberFormat, java.util.ArrayDeque, .ArrayList, .Deque, .HashMap, .HashSet, .List, .Locale, .Map, .Set, org.apache.commons.logging.Log, .LogFactory, org.apache.fontbox.ttf.CmapLookup, org.apache.fontbox.ttf.gsub.GsubWorker, .GsubWorkerFactory, org.apache.fontbox.ttf.model.GsubData, org.apache.pdfbox.contentstream.operator.OperatorName, org.apache.pdfbox.cos.COSArray, .COSBase, .COSDictionary, .COSName, .COSNumber, org.apache.pdfbox.pdfwriter.COSWriter, org.apache.pdfbox.pdmodel.documentinterchange.markedcontent.PDPropertyList, org.apache.pdfbox.pdmodel.font.PDFont, .PDType0Font, org.apache.pdfbox.pdmodel.graphics.color.PDColor, .PDColorSpace, .PDDeviceCMYK, .PDDeviceGray, .PDDeviceN, .PDDeviceRGB, .PDICCBased, .PDPattern, .PDSeparation, org.apache.pdfbox.pdmodel.graphics.form.PDFormXObject, org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject, .PDInlineImage, org.apache.pdfbox.pdmodel.graphics.shading.PDShading, org.apache.pdfbox.pdmodel.graphics.state.PDExtendedGraphicsState, .RenderingMode, org.apache.pdfbox.util.Matrix, .NumberFormatUtil, .StringUtil

Provides the ability to write to a content stream.
Author
Ben Litchfield

Field Summary

Modifier and TypeField and Description
protected final PDDocument
protected final Deque<PDFont>
private final byte[]
private final NumberFormat
private final GsubWorkerFactory
private final Map<PDType0Font, GsubWorker>
protected boolean
private static final Log
protected final Deque<PDColorSpace>
protected final OutputStream
protected final PDResources
protected final Deque<PDColorSpace>

Constructor Summary

AccessConstructor and Description
pack-priv
PDAbstractContentStream(PDDocument
may be null
document
,
OutputStream
The appearances output stream to write to.
outputStream
,
PDResources
The resources to use
resources
)

Create a new appearance stream.

Method Summary

Modifier and TypeMethod and Description
public void
addComment(String
the comment to be added to the content stream
comment
)

Write a comment line.

public void
addRect(float
The lower left x coordinate.
x
,
float
The lower left y coordinate.
y
,
float
The width of the rectangle.
width
,
float
The height of the rectangle.
height
)

Add a rectangle to the current path.

private List<Integer>
public void
beginMarkedContent(COSName
the tag to be added to the content stream
tag
)

Begin a marked content sequence.

public void
beginMarkedContent(COSName
the tag to be added to the content stream
tag
,
int
the marked content identifier (MCID)
mcid
)

Begin a marked content sequence with a reference to the marked content identifier (MCID).

public void
beginMarkedContent(COSName
the tag to be added to the content stream
tag
,
PDPropertyList
property list to be added to the content stream
propertyList
)

Begin a marked content sequence with a reference to an entry in the page resources' Properties dictionary.

public void
beginText()

Begin some text operations.

public void
clip()

Intersects the current clipping path with the current path, using the nonzero rule.

public void
clipEvenOdd()

Intersects the current clipping path with the current path, using the even-odd rule.

public void
close()

Implements java.io.Closeable.close.

Close the content stream.

public void
closeAndFillAndStroke()

Close, fill, and then stroke the path, using the nonzero winding number rule to determine the region to fill.

public void
closeAndFillAndStrokeEvenOdd()

Close, fill, and then stroke the path, using the even-odd rule to determine the region to fill.

public void
closeAndStroke()

Close and stroke the path.

public void
closePath()

Closes the current subpath.

public void
curveTo(float
x coordinate of the point 1
x1
,
float
y coordinate of the point 1
y1
,
float
x coordinate of the point 2
x2
,
float
y coordinate of the point 2
y2
,
float
x coordinate of the point 3
x3
,
float
y coordinate of the point 3
y3
)

Append a cubic Bézier curve to the current path.

public void
curveTo1(float
x coordinate of the point 1
x1
,
float
y coordinate of the point 1
y1
,
float
x coordinate of the point 3
x3
,
float
y coordinate of the point 3
y3
)

Append a cubic Bézier curve to the current path.

public void
curveTo2(float
x coordinate of the point 2
x2
,
float
y coordinate of the point 2
y2
,
float
x coordinate of the point 3
x3
,
float
y coordinate of the point 3
y3
)

Append a cubic Bézier curve to the current path.

public void
drawForm(PDFormXObject
Form XObject
form
)

Draws the given Form XObject at the current location.

public void
drawImage(PDImageXObject
The image to draw.
image
,
float
The x-coordinate to draw the image.
x
,
float
The y-coordinate to draw the image.
y
)

Draw an image at the x,y coordinates, with the default size of the image.

public void
drawImage(PDImageXObject
The image to draw.
image
,
float
The x-coordinate to draw the image.
x
,
float
The y-coordinate to draw the image.
y
,
float
The width to draw the image.
width
,
float
The height to draw the image.
height
)

Draw an image at the x,y coordinates, with the given size.

public void
drawImage(PDImageXObject
The image to draw.
image
,
Matrix
The transformation matrix to apply to the image.
matrix
)

Draw an image at the origin with the given transformation matrix.

public void
drawImage(PDInlineImage
The inline image to draw.
inlineImage
,
float
The x-coordinate to draw the inline image.
x
,
float
The y-coordinate to draw the inline image.
y
)

Draw an inline image at the x,y coordinates, with the default size of the image.

public void
drawImage(PDInlineImage
The inline image to draw.
inlineImage
,
float
The x-coordinate to draw the inline image.
x
,
float
The y-coordinate to draw the inline image.
y
,
float
The width of the inline image to draw.
width
,
float
The height of the inline image to draw.
height
)

Draw an inline image at the x,y coordinates and a certain width and height.

private byte[]
encodeForGsub(GsubWorker gsubWorker, Set<Integer> glyphIds, PDType0Font font, String text)

public void
endMarkedContent()

End a marked content sequence.

public void
endText()

End some text operations.

public void
fill()

Fills the path using the nonzero winding number rule.

public void
fillAndStroke()

Fill and then stroke the path, using the nonzero winding number rule to determine the region to fill.

public void
fillAndStrokeEvenOdd()

Fill and then stroke the path, using the even-odd rule to determine the region to fill.

public void
fillEvenOdd()

Fills the path using the even-odd winding rule.

protected COSName
getName(PDColorSpace colorSpace)

protected boolean
private boolean
public void
lineTo(float
The x coordinate.
x
,
float
The y coordinate.
y
)

Draw a line from the current position to the given coordinates.

public void
moveTo(float
The x coordinate.
x
,
float
The y coordinate.
y
)

Move the current position to the given coordinates.

public void
newLine()

Move to the start of the next line of text.

public void
newLineAtOffset(float
The x translation.
tx
,
float
The y translation.
ty
)

The Td operator.

public void
restoreGraphicsState()

Q operator.

public void
saveGraphicsState()

q operator.

public void
setCharacterSpacing(float
character spacing
spacing
)

Set the character spacing.

public void
setFont(PDFont
The font to use.
font
,
float
The font size to draw the text.
fontSize
)

Set the font and font size to draw text with.

public void
setGraphicsStateParameters(PDExtendedGraphicsState
The extended graphics state to be added to the content stream
state
)

Set an extended graphics state.

public void
setHorizontalScaling(float
number specifying the percentage of the normal width. Default value: 100 (normal width).
scale
)

Set the horizontal scaling to scale / 100.

public void
setLeading(float
The leading in unscaled text units.
leading
)

Sets the text leading.

public void
setLineCapStyle(int
0 for butt cap, 1 for round cap, and 2 for projecting square cap.
lineCapStyle
)

Set the line cap style.

public void
setLineDashPattern(float[]
The pattern array
pattern
,
float
The phase of the pattern
phase
)

Set the line dash pattern.

public void
setLineJoinStyle(int
0 for miter join, 1 for round join, and 2 for bevel join.
lineJoinStyle
)

Set the line join style.

public void
setLineWidth(float
The width which is used for drawing.
lineWidth
)

Set line width to the given value.

protected void
setMaximumFractionDigits(int
the maximum number of digits allowed for fractional numbers
fractionDigitsNumber
)

Sets the maximum number of digits allowed for fractional numbers.

public void
setMiterLimit(float
the new miter limit.
miterLimit
)

Set the miter limit.

public void
setNonStrokingColor(PDColor
Color in a specific color space.
color
)

Sets the non-stroking color and, if necessary, the non-stroking color space.

public void
setNonStrokingColor(Color
The color to set.
color
)

Set the non-stroking color using an AWT color.

public void
setNonStrokingColor(float
The red value.
r
,
float
The green value.
g
,
float
The blue value.
b
)

Set the non-stroking color in the DeviceRGB color space.

public void
setNonStrokingColor(float
The cyan value.
c
,
float
The magenta value.
m
,
float
The yellow value.
y
,
float
The black value.
k
)

Set the non-stroking color in the DeviceCMYK color space.

public void
setNonStrokingColor(float
The gray value.
g
)

Set the non-stroking color in the DeviceGray color space.

protected void
public void
setRenderingMode(RenderingMode
The text rendering mode.
rm
)

Set the text rendering mode.

public void
setStrokingColor(PDColor
Color in a specific color space.
color
)

Sets the stroking color and, if necessary, the stroking color space.

public void
setStrokingColor(Color
The color to set.
color
)

Set the stroking color using an AWT color.

public void
setStrokingColor(float
The red value
r
,
float
The green value.
g
,
float
The blue value.
b
)

Set the stroking color in the DeviceRGB color space.

public void
setStrokingColor(float
The cyan value.
c
,
float
The magenta value.
m
,
float
The yellow value.
y
,
float
The black value.
k
)

Set the stroking color in the DeviceCMYK color space.

public void
setStrokingColor(float
The gray value.
g
)

Set the stroking color in the DeviceGray color space.

protected void
public void
setTextMatrix(Matrix
the transformation matrix
matrix
)

The Tm operator.

public void
setTextRise(float
Specifies the distance, in unscaled text space units, to move the baseline up or down from its default location. 0 restores the default location.
rise
)

Set the text rise value, i.e. move the baseline up or down.

public void
setWordSpacing(float
word spacing
spacing
)

Set the word spacing.

public void
shadingFill(PDShading
Shading resource
shading
)

Fills the clipping area with the given shading.

public void
showText(String
The Unicode text to show.
text
)

Shows the given text at the location specified by the current text matrix.

protected void
showTextInternal(String
The Unicode text to show.
text
)

Outputs a string using the correct encoding and subsetting as required.

public void
showTextWithPositioning(Object[]
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.
textWithPositioningArray
)

Shows the given text at the location specified by the current text matrix with the given interspersed positioning.

public void
stroke()

Stroke the path.

public void
transform(Matrix
the transformation matrix
matrix
)

The cm operator.

protected void
write(String
the text to be added to the content stream
text
)

Writes a string to the content stream as ASCII.

private void
writeAffineTransform(AffineTransform
AffineTransfrom to be added to the content stream
transform
)

Writes an AffineTransform to the content stream as an array.

protected void
writeBytes(byte[]
as byte formatted to be added to the content stream
data
)

Writes binary data to the content stream.

protected void
writeLine()

Writes a newline to the content stream as ASCII.

protected void
writeOperand(float
the real number to be added to the content stream
real
)

Writes a real number to the content stream.

protected void
writeOperand(int
the integer to be added to the content stream
integer
)

Writes an integer number to the content stream.

protected void
writeOperand(COSName
the name to be added to the content stream
name
)

Writes a COSName to the content stream.

protected void
writeOperator(String
the text to be added to the content stream followed by a newline
text
)

Writes a string to the content stream as ASCII.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait