Package org.apache.pdfbox.pdmodel
Class PDAbstractContentStream
java.lang.Object
org.apache.pdfbox.pdmodel.PDAbstractContentStream
- All Implemented Interfaces:
Closeable,AutoCloseable
- Direct Known Subclasses:
PDAppearanceContentStream,PDFormContentStream,PDPageContentStream,PDPatternContentStream
Provides the ability to write to a content stream.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final PDDocumentprivate final byte[]private final NumberFormatprivate final GsubWorkerFactoryprivate final Map<PDType0Font, GsubWorker> protected booleanprivate static final org.apache.commons.logging.Logprotected final Deque<PDColorSpace> protected final OutputStreamprotected final PDResourcesprotected final Deque<PDColorSpace> -
Constructor Summary
ConstructorsConstructorDescriptionPDAbstractContentStream(PDDocument document, OutputStream outputStream, PDResources resources) Create a new appearance stream. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddComment(String comment) Write a comment line.voidaddRect(float x, float y, float width, float height) Add a rectangle to the current path.applyGSUBRules(GsubWorker gsubWorker, ByteArrayOutputStream out, PDType0Font font, String word) Retrieve the glyph IDs for the characters in the specified word, after applying any relevant GSUB rules.voidBegin a marked content sequence.voidbeginMarkedContent(COSName tag, int mcid) Begin a marked content sequence with a reference to the marked content identifier (MCID).voidbeginMarkedContent(COSName tag, PDPropertyList propertyList) Begin a marked content sequence with a reference to an entry in the page resources' Properties dictionary.voidBegin some text operations.voidclip()Intersects the current clipping path with the current path, using the nonzero rule.voidIntersects the current clipping path with the current path, using the even-odd rule.voidclose()Close the content stream.voidClose, fill, and then stroke the path, using the nonzero winding number rule to determine the region to fill.voidClose, fill, and then stroke the path, using the even-odd rule to determine the region to fill.voidClose and stroke the path.voidCloses 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.private byte[]encodeForGsub(GsubWorker gsubWorker, Set<Integer> glyphIds, PDType0Font font, String text) Retrieve the encoded glyph IDs for the characters in the specified text, after applying any relevant GSUB rules.voidEnd a marked content sequence.voidendText()End some text operations.voidfill()Fills the path using the nonzero winding number rule.voidFill and then stroke the path, using the nonzero winding number rule to determine the region to fill.voidFill and then stroke the path, using the even-odd rule to determine the region to fill.voidFills the path using the even-odd winding rule.protected COSNamegetName(PDColorSpace colorSpace) protected booleanisOutside255Interval(int val) private booleanisOutsideOneInterval(double 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.voidQ operator.voidq operator.voidsetCharacterSpacing(float spacing) Set the character spacing.voidSet the font and font size to draw text with.voidSet 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.voidset a marked content point.voidsetMarkedContentPointWithProperties(COSName tag, PDPropertyList propertyList) Set a marked content point with a reference to an entry in the page resources' Properties dictionary.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 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(Color 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.protected voidsetNonStrokingColorSpaceStack(PDColorSpace colorSpace) voidSet the text rendering mode.voidsetStrokingColor(float g) Set the stroking color in the DeviceGray color space.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(Color color) Set the stroking color using an AWT color.voidsetStrokingColor(PDColor color) Sets the stroking color and, if necessary, the stroking color space.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.voidShows 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.voidThe cm operator.protected voidWrites a string to the content stream as ASCII.private voidwriteAffineTransform(AffineTransform transform) Writes an AffineTransform to the content stream as an array.protected voidwriteBytes(byte[] data) Writes binary data to the content stream.protected voidWrites 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 Details
-
LOG
private static final org.apache.commons.logging.Log LOG -
document
-
outputStream
-
resources
-
inTextMode
protected boolean inTextMode -
fontStack
-
nonStrokingColorSpaceStack
-
strokingColorSpaceStack
-
formatDecimal
-
formatBuffer
private final byte[] formatBuffer -
gsubWorkers
-
gsubWorkerFactory
-
-
Constructor Details
-
PDAbstractContentStream
PDAbstractContentStream(PDDocument document, OutputStream outputStream, PDResources resources) Create a new appearance stream.- Parameters:
document- may be nulloutputStream- The appearances output stream to write to.resources- The resources to use
-
-
Method Details
-
setMaximumFractionDigits
protected void setMaximumFractionDigits(int fractionDigitsNumber) Sets the maximum number of digits allowed for fractional numbers.- Parameters:
fractionDigitsNumber- the maximum number of digits allowed for fractional numbers- See Also:
-
beginText
Begin 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
End 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
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
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
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
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
Sets the text leading.- Parameters:
leading- The leading in unscaled text units.- Throws:
IOException- If there is an error writing to the stream.
-
newLine
Move 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
The 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
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
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
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
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
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
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
q operator. Saves the current graphics state.- Throws:
IOException- If an error occurs while writing to the stream.
-
restoreGraphicsState
Q operator. Restores the current graphics state.- Throws:
IOException- If an error occurs while writing to the stream.
-
getName
-
setStrokingColor
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
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
Set the stroking color in the DeviceRGB color space. Range is 0..1.- 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.
-
setStrokingColor
Set 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
Set 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
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
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
Set the non-stroking color in the DeviceRGB color space. Range is 0..1.- 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
Set 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
Set 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
Add 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
Append 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
Append 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
Append 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
Move 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
Draw 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
Stroke the path.- Throws:
IOException- If the content stream could not be writtenIllegalStateException- If the method was called within a text block.
-
closeAndStroke
Close and stroke the path.- Throws:
IOException- If the content stream could not be writtenIllegalStateException- If the method was called within a text block.
-
fill
Fills 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
Fills 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
Fill 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
Fill 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
Close, 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
Close, 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
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
Closes the current subpath.- Throws:
IOException- If the content stream could not be writtenIllegalStateException- If the method was called within a text block.
-
clip
Intersects 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
Intersects 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
Set 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
Set 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
Set 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
Set 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
Set 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
Begin a marked content sequence.- Parameters:
tag- the tag to be added to the content stream- Throws:
IOException- If the content stream could not be written
-
beginMarkedContent
Begin a marked content sequence with a reference to the marked content identifier (MCID).- Parameters:
tag- the tag to be added to the content streammcid- the marked content identifier (MCID)- Throws:
IOException- If the content stream could not be written
-
beginMarkedContent
Begin a marked content sequence with a reference to an entry in the page resources' Properties dictionary.- Parameters:
tag- the tag to be added to the content streampropertyList- property list to be added to the content stream- Throws:
IOException- If the content stream could not be written
-
endMarkedContent
End a marked content sequence.- Throws:
IOException- If the content stream could not be written
-
setMarkedContentPoint
set a marked content point.- Parameters:
tag- the tag to be added to the content stream- Throws:
IOException- If the content stream could not be written
-
setMarkedContentPointWithProperties
public void setMarkedContentPointWithProperties(COSName tag, PDPropertyList propertyList) throws IOException Set a marked content point with a reference to an entry in the page resources' Properties dictionary.- Parameters:
tag- the tag to be added to the content streampropertyList- property list to be added to the content stream- Throws:
IOException- If the content stream could not be written
-
setGraphicsStateParameters
Set an extended graphics state.- Parameters:
state- The extended graphics state to be added to the content stream- Throws:
IOException- If the content stream could not be written.
-
addComment
Write a comment line.- Parameters:
comment- the comment to be added to the content stream- 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
Writes a real number to the content stream.- Parameters:
real- the real number to be added to the content stream- Throws:
IOException- If the underlying stream has a problem being written to.IllegalArgumentException- if the parameter is not a finite number
-
writeOperand
Writes an integer number to the content stream.- Parameters:
integer- the integer to be added to the content stream- Throws:
IOException- If the underlying stream has a problem being written to.
-
writeOperand
Writes a COSName to the content stream.- Parameters:
name- the name to be added to the content stream- Throws:
IOException- If the underlying stream has a problem being written to.
-
writeOperator
Writes a string to the content stream as ASCII.- Parameters:
text- the text to be added to the content stream followed by a newline- Throws:
IOException- If the underlying stream has a problem being written to.
-
write
Writes a string to the content stream as ASCII.- Parameters:
text- the text to be added to the content stream- Throws:
IOException- If the underlying stream has a problem being written to.
-
writeLine
Writes a newline to the content stream as ASCII.- Throws:
IOException- If the underlying stream has a problem being written to.
-
writeBytes
Writes binary data to the content stream.- Parameters:
data- as byte formatted to be added to the content stream- Throws:
IOException- If the underlying stream has a problem being written to.
-
writeAffineTransform
Writes an AffineTransform to the content stream as an array.- Parameters:
transform- AffineTransform to be added to the content stream- Throws:
IOException- If the underlying stream has a problem being written to.
-
close
Close 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) -
isOutsideOneInterval
private boolean isOutsideOneInterval(double val) -
setStrokingColorSpaceStack
-
setNonStrokingColorSpaceStack
-
setCharacterSpacing
Set 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
Set 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
Set 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
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
Set 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- If the content stream could not be written.
-
encodeForGsub
private byte[] encodeForGsub(GsubWorker gsubWorker, Set<Integer> glyphIds, PDType0Font font, String text) throws IOException Retrieve the encoded glyph IDs for the characters in the specified text, after applying any relevant GSUB rules. The glyph IDs used are also added to the specified glyph ID set.- Parameters:
gsubWorker- The GSUB worker which defines the GSUB transformations to apply.glyphIds- The set of glyph IDs which is to be populated with the glyph IDs found in the text.font- The font whose cmap table will be used to map characters to glyph IDs.text- The text which is being converted from characters to glyph IDs.- Returns:
- The encoded glyph IDs for the characters in the specified text, after applying any relevant GSUB rules.
- Throws:
IOException- If there is an error during encoding.IllegalStateException- If we cannot find a glyph ID for any characters in the specified text.
-
applyGSUBRules
private List<Integer> applyGSUBRules(GsubWorker gsubWorker, ByteArrayOutputStream out, PDType0Font font, String word) throws IOException Retrieve the glyph IDs for the characters in the specified word, after applying any relevant GSUB rules. The encoded glyph IDs are also written to the specified output stream.- Parameters:
gsubWorker- The GSUB worker which defines the GSUB transformations to apply.out- The output stream to write the glyph IDs to.font- The font whose cmap table will be used to map characters to glyph IDs.word- The word which is being converted from characters to glyph IDs.- Returns:
- The glyph IDs for the characters in the specified word, after applying any relevant GSUB rules.
- Throws:
IllegalStateException- If we cannot find a glyph ID for any characters in the specified word.IOException
-