Package org.apache.pdfbox.pdmodel
Class PDPageContentStream
- java.lang.Object
-
- org.apache.pdfbox.pdmodel.PDPageContentStream
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
public final class PDPageContentStream extends java.lang.Object implements java.io.Closeable
Provides the ability to write to a page content stream.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
PDPageContentStream.AppendMode
This is to choose what to do with the stream: overwrite, append or prepend.
-
Field Summary
Fields Modifier and Type Field Description private PDDocument
document
private java.util.Stack<PDFont>
fontStack
private byte[]
formatBuffer
private java.text.NumberFormat
formatDecimal
private boolean
inTextMode
private static org.apache.commons.logging.Log
LOG
private java.util.Stack<PDColorSpace>
nonStrokingColorSpaceStack
private java.io.OutputStream
output
private PDResources
resources
private boolean
sourcePageHadContents
private java.util.Stack<PDColorSpace>
strokingColorSpaceStack
-
Constructor Summary
Constructors Constructor Description PDPageContentStream(PDDocument doc, PDFormXObject form, java.io.OutputStream outputStream)
Create a new appearance stream.PDPageContentStream(PDDocument doc, PDTilingPattern pattern, java.io.OutputStream outputStream)
Create a new appearance stream.PDPageContentStream(PDDocument doc, PDAppearanceStream appearance)
Create a new appearance stream.PDPageContentStream(PDDocument doc, PDAppearanceStream appearance, java.io.OutputStream outputStream)
Create a new appearance stream.PDPageContentStream(PDDocument document, PDPage sourcePage)
Create a new PDPage content stream.PDPageContentStream(PDDocument document, PDPage sourcePage, boolean appendContent, boolean compress)
PDPageContentStream(PDDocument document, PDPage sourcePage, boolean appendContent, boolean compress, boolean resetContext)
PDPageContentStream(PDDocument document, PDPage sourcePage, PDPageContentStream.AppendMode appendContent, boolean compress)
Create a new PDPage content stream.PDPageContentStream(PDDocument document, PDPage sourcePage, PDPageContentStream.AppendMode appendContent, boolean compress, boolean resetContext)
Create a new PDPage content stream.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addBezier31(float x1, float y1, float x3, float y3)
Deprecated.UsecurveTo1(float, float, float, float)
instead.void
addBezier312(float x1, float y1, float x2, float y2, float x3, float y3)
Deprecated.UsecurveTo(float, float, float, float, float, float)
instead.void
addBezier32(float x2, float y2, float x3, float y3)
Deprecated.UsecurveTo2(float, float, float, float)
instead.void
addComment(java.lang.String comment)
Write a comment line.void
addLine(float xStart, float yStart, float xEnd, float yEnd)
Deprecated.Usemoveto(xStart,yStart)
followed bylineTo(xEnd,yEnd)
.void
addPolygon(float[] x, float[] y)
Deprecated.UsemoveTo(float, float)
andlineTo(float, float)
methods instead.void
addRect(float x, float y, float width, float height)
Add a rectangle to the current path.void
appendCOSName(COSName name)
Deprecated.Usage of this method is discouraged.void
appendRawCommands(byte[] commands)
Deprecated.Usage of this method is discouraged.void
appendRawCommands(double data)
Deprecated.Usage of this method is discouraged.void
appendRawCommands(float data)
Deprecated.Usage of this method is discouraged.void
appendRawCommands(int data)
Deprecated.Usage of this method is discouraged.void
appendRawCommands(java.lang.String commands)
Deprecated.Usage of this method is discouraged.void
beginMarkedContent(COSName tag)
Begin a marked content sequence.void
beginMarkedContent(COSName tag, PDPropertyList propertyList)
Begin a marked content sequence with a reference to an entry in the page resources' Properties dictionary.void
beginMarkedContentSequence(COSName tag)
Deprecated.UsebeginMarkedContent(org.apache.pdfbox.cos.COSName)
instead.void
beginMarkedContentSequence(COSName tag, COSName propsName)
Deprecated.UsebeginMarkedContent(COSName, PDPropertyList)
instead.void
beginText()
Begin some text operations.void
clip()
Intersects the current clipping path with the current path, using the nonzero rule.void
clipEvenOdd()
Intersects the current clipping path with the current path, using the even-odd rule.void
clipPath(int windingRule)
Deprecated.Useclip()
orclipEvenOdd()
instead.void
close()
Close the content stream.void
closeAndFillAndStroke()
Close, fill, and then stroke the path, using the nonzero winding number rule to determine the region to fill.void
closeAndFillAndStrokeEvenOdd()
Close, fill, and then stroke the path, using the even-odd rule to determine the region to fill.void
closeAndStroke()
Close and stroke the path.void
closePath()
Closes the current subpath.void
closeSubPath()
Deprecated.UseclosePath()
instead.void
concatenate2CTM(double a, double b, double c, double d, double e, double f)
Deprecated.Usetransform(org.apache.pdfbox.util.Matrix)
instead.void
concatenate2CTM(java.awt.geom.AffineTransform at)
Deprecated.Usetransform(org.apache.pdfbox.util.Matrix)
instead.void
curveTo(float x1, float y1, float x2, float y2, float x3, float y3)
Append a cubic Bézier curve to the current path.void
curveTo1(float x1, float y1, float x3, float y3)
Append a cubic Bézier curve to the current path.void
curveTo2(float x2, float y2, float x3, float y3)
Append a cubic Bézier curve to the current path.void
drawForm(PDFormXObject form)
Draws the given Form XObject at the current location.void
drawImage(PDImageXObject image, float x, float y)
Draw an image at the x,y coordinates, with the default size of the image.void
drawImage(PDImageXObject image, float x, float y, float width, float height)
Draw an image at the x,y coordinates, with the given size.void
drawImage(PDImageXObject image, Matrix matrix)
Draw an image at the origin with the given transformation matrix.void
drawImage(PDInlineImage inlineImage, float x, float y)
Draw an inline image at the x,y coordinates, with the default size of the image.void
drawImage(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.void
drawInlineImage(PDInlineImage inlineImage, float x, float y)
Deprecated.UsedrawImage(PDInlineImage, float, float)
instead.void
drawInlineImage(PDInlineImage inlineImage, float x, float y, float width, float height)
Deprecated.UsedrawImage(PDInlineImage, float, float, float, float)
instead.void
drawLine(float xStart, float yStart, float xEnd, float yEnd)
Deprecated.void
drawPolygon(float[] x, float[] y)
Deprecated.UsemoveTo(float, float)
andlineTo(float, float)
methods instead.void
drawString(java.lang.String text)
Deprecated.UseshowText(java.lang.String)
instead.void
drawXObject(PDXObject xobject, float x, float y, float width, float height)
Deprecated.void
drawXObject(PDXObject xobject, java.awt.geom.AffineTransform transform)
Deprecated.void
endMarkedContent()
End a marked content sequence.void
endMarkedContentSequence()
Deprecated.UseendMarkedContent()
instead.void
endText()
End some text operations.void
fill()
Fills the path using the nonzero winding number rule.void
fill(int windingRule)
Deprecated.Usefill()
orfillEvenOdd()
instead.void
fillAndStroke()
Fill and then stroke the path, using the nonzero winding number rule to determine the region to fill.void
fillAndStrokeEvenOdd()
Fill and then stroke the path, using the even-odd rule to determine the region to fill.void
fillEvenOdd()
Fills the path using the even-odd winding rule.void
fillPolygon(float[] x, float[] y)
Deprecated.UsemoveTo(float, float)
andlineTo(float, float)
methods instead.void
fillRect(float x, float y, float width, float height)
Deprecated.UseaddRect(float, float, float, float)
followed byfill()
instead.private COSName
getName(PDColorSpace colorSpace)
private boolean
isOutside255Interval(int val)
private boolean
isOutsideOneInterval(double val)
void
lineTo(float x, float y)
Draw a line from the current position to the given coordinates.void
moveTextPositionByAmount(float tx, float ty)
Deprecated.UsenewLineAtOffset(float, float)
instead.void
moveTo(float x, float y)
Move the current position to the given coordinates.void
newLine()
Move to the start of the next line of text.void
newLineAtOffset(float tx, float ty)
The Td operator.void
restoreGraphicsState()
Q operator.void
saveGraphicsState()
q operator.void
setCharacterSpacing(float spacing)
Set the character spacing.void
setFont(PDFont font, float fontSize)
Set the font and font size to draw text with.void
setGraphicsStateParameters(PDExtendedGraphicsState state)
Set an extended graphics state.void
setHorizontalScaling(float scale)
Set the horizontal scaling to scale / 100.void
setLeading(double leading)
Deprecated.void
setLeading(float leading)
Sets the text leading.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 line width to the given value.void
setMiterLimit(float miterLimit)
Set the miter limit.void
setNonStrokingColor(double g)
Deprecated.void
setNonStrokingColor(double c, double m, double y, double k)
Deprecated.void
setNonStrokingColor(float g)
Set the non-stroking color in the DeviceGray color space.void
setNonStrokingColor(float[] components)
Deprecated.UsesetNonStrokingColor(PDColor)
instead.void
setNonStrokingColor(float r, float g, float b)
Set the non-stroking color in the DeviceRGB color space.void
setNonStrokingColor(float c, float m, float y, float k)
Set the non-stroking color in the DeviceCMYK color space.void
setNonStrokingColor(int g)
Deprecated.void
setNonStrokingColor(int r, int g, int b)
Deprecated.void
setNonStrokingColor(int c, int m, int y, int k)
Set the non-stroking color in the DeviceCMYK color space.void
setNonStrokingColor(java.awt.Color color)
Set the non-stroking color using an AWT color.void
setNonStrokingColor(PDColor color)
Sets the non-stroking color and, if necessary, the non-stroking color space.void
setNonStrokingColorSpace(PDColorSpace colorSpace)
Deprecated.UsesetNonStrokingColor(PDColor)
instead.private void
setNonStrokingColorSpaceStack(PDColorSpace colorSpace)
void
setRenderingMode(RenderingMode rm)
Set the text rendering mode.void
setStrokingColor(double g)
Deprecated.void
setStrokingColor(float g)
Set the stroking color in the DeviceGray color space.void
setStrokingColor(float[] components)
Deprecated.UsesetStrokingColor(PDColor)
instead.void
setStrokingColor(float r, float g, float b)
Set the stroking color in the DeviceRGB color space.void
setStrokingColor(float c, float m, float y, float k)
Set the stroking color in the DeviceCMYK color space.void
setStrokingColor(int g)
Deprecated.UsesetStrokingColor(g/255f)
instead.void
setStrokingColor(int r, int g, int b)
Deprecated.void
setStrokingColor(int c, int m, int y, int k)
Deprecated.UsesetStrokingColor(c/255f, m/255f, y/255f, k/255f)
instead.void
setStrokingColor(java.awt.Color color)
Set the stroking color using an AWT color.void
setStrokingColor(PDColor color)
Sets the stroking color and, if necessary, the stroking color space.void
setStrokingColorSpace(PDColorSpace colorSpace)
Deprecated.private void
setStrokingColorSpaceStack(PDColorSpace colorSpace)
void
setTextMatrix(double a, double b, double c, double d, double e, double f)
Deprecated.UsesetTextMatrix(Matrix)
instead.void
setTextMatrix(java.awt.geom.AffineTransform matrix)
Deprecated.UsesetTextMatrix(Matrix)
instead.void
setTextMatrix(Matrix matrix)
The Tm operator.void
setTextRise(float rise)
Set the text rise value, i.e.void
setTextRotation(double angle, double tx, double ty)
Deprecated.UsesetTextMatrix(Matrix)
instead.void
setTextScaling(double sx, double sy, double tx, double ty)
Deprecated.UsesetTextMatrix(Matrix)
instead.void
setTextTranslation(double tx, double ty)
Deprecated.UsesetTextMatrix(Matrix)
instead.void
setWordSpacing(float spacing)
Set the word spacing.void
shadingFill(PDShading shading)
Fills the clipping area with the given shading.void
showText(java.lang.String text)
Shows the given text at the location specified by the current text matrix.protected void
showTextInternal(java.lang.String text)
Outputs a string using the correct encoding and subsetting as required.void
showTextWithPositioning(java.lang.Object[] textWithPositioningArray)
Shows the given text at the location specified by the current text matrix with the given interspersed positioning.void
stroke()
Stroke the path.void
transform(Matrix matrix)
The cm operator.private void
write(java.lang.String text)
Writes a string to the content stream as ASCII.private void
writeAffineTransform(java.awt.geom.AffineTransform transform)
Writes an AffineTransform to the content stream as an array.private void
writeBytes(byte[] data)
Writes binary data to the content stream.private void
writeLine()
Writes a newline to the content stream as ASCII.protected void
writeOperand(float real)
Writes a real number to the content stream.private void
writeOperand(int integer)
Writes an integer number to the content stream.private void
writeOperand(COSName name)
Writes a COSName to the content stream.private void
writeOperator(java.lang.String text)
Writes a string to the content stream as ASCII.
-
-
-
Field Detail
-
LOG
private static final org.apache.commons.logging.Log LOG
-
document
private final PDDocument document
-
output
private java.io.OutputStream output
-
resources
private PDResources resources
-
inTextMode
private boolean inTextMode
-
fontStack
private final java.util.Stack<PDFont> fontStack
-
nonStrokingColorSpaceStack
private final java.util.Stack<PDColorSpace> nonStrokingColorSpaceStack
-
strokingColorSpaceStack
private final java.util.Stack<PDColorSpace> strokingColorSpaceStack
-
formatDecimal
private final java.text.NumberFormat formatDecimal
-
formatBuffer
private final byte[] formatBuffer
-
sourcePageHadContents
private boolean sourcePageHadContents
-
-
Constructor Detail
-
PDPageContentStream
public PDPageContentStream(PDDocument document, PDPage sourcePage) throws java.io.IOException
Create a new PDPage content stream. This constructor overwrites all existing content streams of this page.- Parameters:
document
- The document the page is part of.sourcePage
- The page to write the contents to.- Throws:
java.io.IOException
- If there is an error writing to the page contents.
-
PDPageContentStream
@Deprecated public PDPageContentStream(PDDocument document, PDPage sourcePage, boolean appendContent, boolean compress) throws java.io.IOException
Create a new PDPage content stream.- Parameters:
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.- Throws:
java.io.IOException
- If there is an error writing to the page contents.
-
PDPageContentStream
public PDPageContentStream(PDDocument document, PDPage sourcePage, PDPageContentStream.AppendMode appendContent, boolean compress) throws java.io.IOException
Create a new PDPage content stream. If the appendContent parameter is set toPDPageContentStream.AppendMode.APPEND
, you may want to usePDPageContentStream(PDDocument, PDPage, PDPageContentStream.AppendMode, boolean, boolean)
instead, with the fifth parameter set to true.- Parameters:
document
- The document the page is part of.sourcePage
- The page to write the contents to.appendContent
- Indicates whether content will be overwritten, appended or prepended.compress
- Tell if the content stream should compress the page contents.- Throws:
java.io.IOException
- If there is an error writing to the page contents.
-
PDPageContentStream
@Deprecated public PDPageContentStream(PDDocument document, PDPage sourcePage, boolean appendContent, boolean compress, boolean resetContext) throws java.io.IOException
Deprecated.Create a new PDPage content stream.- Parameters:
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. You should use this when appending to an existing stream, because the existing stream may have changed graphic properties (e.g. scaling, rotation).- Throws:
java.io.IOException
- If there is an error writing to the page contents.
-
PDPageContentStream
public PDPageContentStream(PDDocument document, PDPage sourcePage, PDPageContentStream.AppendMode appendContent, boolean compress, boolean resetContext) throws java.io.IOException
Create a new PDPage content stream.- Parameters:
document
- The document the page is part of.sourcePage
- The page to write the contents to.appendContent
- Indicates whether content will be overwritten, appended or prepended.compress
- Tell if the content stream should compress the page contents.resetContext
- Tell if the graphic context should be reset. This is only relevant when the appendContent parameter is set toPDPageContentStream.AppendMode.APPEND
. You should use this when appending to an existing stream, because the existing stream may have changed graphic properties (e.g. scaling, rotation).- Throws:
java.io.IOException
- If there is an error writing to the page contents.
-
PDPageContentStream
public PDPageContentStream(PDDocument doc, PDAppearanceStream appearance) throws java.io.IOException
Create a new appearance stream. Note that this is not actually a "page" content stream.- Parameters:
doc
- The document the page is part of.appearance
- The appearance stream to write to.- Throws:
java.io.IOException
- If there is an error writing to the page contents.
-
PDPageContentStream
public PDPageContentStream(PDDocument doc, PDAppearanceStream appearance, java.io.OutputStream outputStream) throws java.io.IOException
Create a new appearance stream. Note that this is not actually a "page" content stream.- Parameters:
doc
- The document the appearance is part of.appearance
- The appearance stream to add to.outputStream
- The appearances output stream to write to.- Throws:
java.io.IOException
- If there is an error writing to the page contents.
-
PDPageContentStream
public PDPageContentStream(PDDocument doc, PDFormXObject form, java.io.OutputStream outputStream) throws java.io.IOException
Create a new appearance stream. Note that this is not actually a "page" content stream.- Parameters:
doc
- The document the appearance is part of.form
- The XObject form to add to.outputStream
- The output stream to write to.- Throws:
java.io.IOException
- If there is an error writing to the page contents.
-
PDPageContentStream
public PDPageContentStream(PDDocument doc, PDTilingPattern pattern, java.io.OutputStream outputStream) throws java.io.IOException
Create a new appearance stream. Note that this is not actually a "page" content stream.- Parameters:
doc
- The document the appearance is part of.pattern
- The pattern to add to.outputStream
- The output stream to write to.- Throws:
java.io.IOException
- If there is an error writing to the page contents.
-
-
Method Detail
-
beginText
public void beginText() throws java.io.IOException
Begin some text operations.- Throws:
java.io.IOException
- If there is an error writing to the stream or if you attempt to nest beginText calls.java.lang.IllegalStateException
- If the method was not allowed to be called at this time.
-
endText
public void endText() throws java.io.IOException
End some text operations.- Throws:
java.io.IOException
- If there is an error writing to the stream or if you attempt to nest endText calls.java.lang.IllegalStateException
- If the method was not allowed to be called at this time.
-
setFont
public void setFont(PDFont font, float fontSize) throws java.io.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:
java.io.IOException
- If there is an error writing the font information.
-
drawString
@Deprecated public void drawString(java.lang.String text) throws java.io.IOException
Deprecated.UseshowText(java.lang.String)
instead.This will draw a string at the current location on the screen.- Parameters:
text
- The text to draw.- Throws:
java.io.IOException
- If an io exception occurs.
-
showTextWithPositioning
public void showTextWithPositioning(java.lang.Object[] textWithPositioningArray) throws java.io.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:
java.io.IOException
- if an io exception occurs.
-
showText
public void showText(java.lang.String text) throws java.io.IOException
Shows the given text at the location specified by the current text matrix.- Parameters:
text
- The Unicode text to show.- Throws:
java.io.IOException
- If an io exception occurs.java.lang.IllegalArgumentException
- if a character isn't supported by the current font
-
showTextInternal
protected void showTextInternal(java.lang.String text) throws java.io.IOException
Outputs a string using the correct encoding and subsetting as required.- Parameters:
text
- The Unicode text to show.- Throws:
java.io.IOException
- If an io exception occurs.
-
setLeading
@Deprecated public void setLeading(double leading) throws java.io.IOException
Deprecated.Sets the text leading.- Parameters:
leading
- The leading in unscaled text units.- Throws:
java.io.IOException
- If there is an error writing to the stream.
-
setLeading
public void setLeading(float leading) throws java.io.IOException
Sets the text leading.- Parameters:
leading
- The leading in unscaled text units.- Throws:
java.io.IOException
- If there is an error writing to the stream.
-
newLine
public void newLine() throws java.io.IOException
Move to the start of the next line of text. Requires the leading (seesetLeading(double)
) to have been set.- Throws:
java.io.IOException
- If there is an error writing to the stream.
-
moveTextPositionByAmount
@Deprecated public void moveTextPositionByAmount(float tx, float ty) throws java.io.IOException
Deprecated.UsenewLineAtOffset(float, float)
instead.The Td operator. A current text matrix will be replaced with a new one (1 0 0 1 x y).- Parameters:
tx
- The x translation.ty
- The y translation.- Throws:
java.io.IOException
- If there is an error writing to the stream.
-
newLineAtOffset
public void newLineAtOffset(float tx, float ty) throws java.io.IOException
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:
java.io.IOException
- If there is an error writing to the stream.java.lang.IllegalStateException
- If the method was not allowed to be called at this time.
-
setTextMatrix
@Deprecated public void setTextMatrix(double a, double b, double c, double d, double e, double f) throws java.io.IOException
Deprecated.UsesetTextMatrix(Matrix)
instead.The Tm operator. Sets the text matrix to the given values. A current text matrix will be replaced with the new one.- Parameters:
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.- Throws:
java.io.IOException
- If there is an error writing to the stream.
-
setTextMatrix
@Deprecated public void setTextMatrix(java.awt.geom.AffineTransform matrix) throws java.io.IOException
Deprecated.UsesetTextMatrix(Matrix)
instead.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:
java.io.IOException
- If there is an error writing to the stream.
-
setTextMatrix
public void setTextMatrix(Matrix matrix) throws java.io.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:
java.io.IOException
- If there is an error writing to the stream.java.lang.IllegalStateException
- If the method was not allowed to be called at this time.
-
setTextScaling
@Deprecated public void setTextScaling(double sx, double sy, double tx, double ty) throws java.io.IOException
Deprecated.UsesetTextMatrix(Matrix)
instead.The Tm operator. Sets the text matrix to the given scaling and translation values. A current text matrix will be replaced with the new one.- Parameters:
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.- Throws:
java.io.IOException
- If there is an error writing to the stream.
-
setTextTranslation
@Deprecated public void setTextTranslation(double tx, double ty) throws java.io.IOException
Deprecated.UsesetTextMatrix(Matrix)
instead.The Tm operator. Sets the text matrix to the given translation values. A current text matrix will be replaced with the new one.- Parameters:
tx
- The translation value in x-direction.ty
- The translation value in y-direction.- Throws:
java.io.IOException
- If there is an error writing to the stream.
-
setTextRotation
@Deprecated public void setTextRotation(double angle, double tx, double ty) throws java.io.IOException
Deprecated.UsesetTextMatrix(Matrix)
instead.The Tm operator. Sets the text matrix to the given rotation and translation values. A current text matrix will be replaced with the new one.- Parameters:
angle
- The angle used for the counterclockwise rotation in radians.tx
- The translation value in x-direction.ty
- The translation value in y-direction.- Throws:
java.io.IOException
- If there is an error writing to the stream.
-
drawImage
public void drawImage(PDImageXObject image, float x, float y) throws java.io.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:
java.io.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 java.io.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:
java.io.IOException
- If there is an error writing to the stream.java.lang.IllegalStateException
- If the method was called within a text block.
-
drawImage
public void drawImage(PDImageXObject image, Matrix matrix) throws java.io.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:
java.io.IOException
- If there is an error writing to the stream.java.lang.IllegalStateException
- If the method was called within a text block.
-
drawInlineImage
@Deprecated public void drawInlineImage(PDInlineImage inlineImage, float x, float y) throws java.io.IOException
Deprecated.UsedrawImage(PDInlineImage, float, float)
instead.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:
java.io.IOException
- If there is an error writing to the stream.
-
drawImage
public void drawImage(PDInlineImage inlineImage, float x, float y) throws java.io.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:
java.io.IOException
- If there is an error writing to the stream.
-
drawInlineImage
@Deprecated public void drawInlineImage(PDInlineImage inlineImage, float x, float y, float width, float height) throws java.io.IOException
Deprecated.UsedrawImage(PDInlineImage, float, float, float, float)
instead.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:
java.io.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 java.io.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:
java.io.IOException
- If there is an error writing to the stream.java.lang.IllegalStateException
- If the method was called within a text block.
-
drawXObject
@Deprecated public void drawXObject(PDXObject xobject, float x, float y, float width, float height) throws java.io.IOException
Deprecated.Draw an xobject(form or image) at the x,y coordinates and a certain width and height.- Parameters:
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.- Throws:
java.io.IOException
- If there is an error writing to the stream.
-
drawXObject
@Deprecated public void drawXObject(PDXObject xobject, java.awt.geom.AffineTransform transform) throws java.io.IOException
Deprecated.Draw an xobject(form or image) using the givenAffineTransform
to position the xobject.- Parameters:
xobject
- The xobject to draw.transform
- the transformation matrix- Throws:
java.io.IOException
- If there is an error writing to the stream.java.lang.IllegalStateException
- If the method was called within a text block.
-
drawForm
public void drawForm(PDFormXObject form) throws java.io.IOException
Draws the given Form XObject at the current location.- Parameters:
form
- Form XObject- Throws:
java.io.IOException
- if the content stream could not be writtenjava.lang.IllegalStateException
- If the method was called within a text block.
-
concatenate2CTM
@Deprecated public void concatenate2CTM(double a, double b, double c, double d, double e, double f) throws java.io.IOException
Deprecated.Usetransform(org.apache.pdfbox.util.Matrix)
instead.The cm operator. Concatenates the current transformation matrix with the given values.- Parameters:
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.- Throws:
java.io.IOException
- If there is an error writing to the stream.
-
concatenate2CTM
@Deprecated public void concatenate2CTM(java.awt.geom.AffineTransform at) throws java.io.IOException
Deprecated.Usetransform(org.apache.pdfbox.util.Matrix)
instead.The cm operator. Concatenates the current transformation matrix with the givenAffineTransform
.- Parameters:
at
- the transformation matrix- Throws:
java.io.IOException
- If there is an error writing to the stream.
-
transform
public void transform(Matrix matrix) throws java.io.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:
java.io.IOException
- If there is an error writing to the stream.
-
saveGraphicsState
public void saveGraphicsState() throws java.io.IOException
q operator. Saves the current graphics state.- Throws:
java.io.IOException
- If an error occurs while writing to the stream.
-
restoreGraphicsState
public void restoreGraphicsState() throws java.io.IOException
Q operator. Restores the current graphics state.- Throws:
java.io.IOException
- If an error occurs while writing to the stream.
-
setStrokingColorSpace
@Deprecated public void setStrokingColorSpace(PDColorSpace colorSpace) throws java.io.IOException
Deprecated.Set the stroking color space. This will add the colorspace to the PDResources if necessary.- Parameters:
colorSpace
- The colorspace to write.- Throws:
java.io.IOException
- If there is an error writing the colorspace.
-
setNonStrokingColorSpace
@Deprecated public void setNonStrokingColorSpace(PDColorSpace colorSpace) throws java.io.IOException
Deprecated.UsesetNonStrokingColor(PDColor)
instead.Set the stroking color space. This will add the colorspace to the PDResources if necessary.- Parameters:
colorSpace
- The colorspace to write.- Throws:
java.io.IOException
- If there is an error writing the colorspace.
-
getName
private COSName getName(PDColorSpace colorSpace) throws java.io.IOException
- Throws:
java.io.IOException
-
setStrokingColor
public void setStrokingColor(PDColor color) throws java.io.IOException
Sets the stroking color and, if necessary, the stroking color space.- Parameters:
color
- Color in a specific color space.- Throws:
java.io.IOException
- If an IO error occurs while writing to the stream.
-
setStrokingColor
public void setStrokingColor(java.awt.Color color) throws java.io.IOException
Set the stroking color using an AWT color. Conversion uses the default sRGB color space.- Parameters:
color
- The color to set.- Throws:
java.io.IOException
- If an IO error occurs while writing to the stream.
-
setStrokingColor
@Deprecated public void setStrokingColor(float[] components) throws java.io.IOException
Deprecated.UsesetStrokingColor(PDColor)
instead.Set the color components of current stroking color space.- Parameters:
components
- The components to set for the current color.- Throws:
java.io.IOException
- If there is an error while writing to the stream.
-
setStrokingColor
public void setStrokingColor(float r, float g, float b) throws java.io.IOException
Set 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:
java.io.IOException
- If an IO error occurs while writing to the stream.java.lang.IllegalArgumentException
- If the parameters are invalid.
-
setStrokingColor
@Deprecated public void setStrokingColor(int r, int g, int b) throws java.io.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:
java.io.IOException
- If an IO error occurs while writing to the stream.java.lang.IllegalArgumentException
- If the parameters are invalid.
-
setStrokingColor
@Deprecated public void setStrokingColor(int c, int m, int y, int k) throws java.io.IOException
Deprecated.UsesetStrokingColor(c/255f, m/255f, y/255f, k/255f)
instead.Set the 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:
java.io.IOException
- If an IO error occurs while writing to the stream.java.lang.IllegalArgumentException
- If the parameters are invalid.
-
setStrokingColor
public void setStrokingColor(float c, float m, float y, float k) throws java.io.IOException
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:
java.io.IOException
- If an IO error occurs while writing to the stream.java.lang.IllegalArgumentException
- If the parameters are invalid.
-
setStrokingColor
@Deprecated public void setStrokingColor(int g) throws java.io.IOException
Deprecated.UsesetStrokingColor(g/255f)
instead.Set the stroking color in the DeviceGray color space. Range is 0..255.- Parameters:
g
- The gray value.- Throws:
java.io.IOException
- If an IO error occurs while writing to the stream.java.lang.IllegalArgumentException
- If the parameter is invalid.
-
setStrokingColor
@Deprecated public void setStrokingColor(double g) throws java.io.IOException
Deprecated.Set the stroking color in the DeviceGray color space. Range is 0..1.- Parameters:
g
- The gray value.- Throws:
java.io.IOException
- If an IO error occurs while writing to the stream.java.lang.IllegalArgumentException
- If the parameter is invalid.
-
setStrokingColor
public void setStrokingColor(float g) throws java.io.IOException
Set the stroking color in the DeviceGray color space. Range is 0..1.- Parameters:
g
- The gray value.- Throws:
java.io.IOException
- If an IO error occurs while writing to the stream.java.lang.IllegalArgumentException
- If the parameter is invalid.
-
setNonStrokingColor
public void setNonStrokingColor(PDColor color) throws java.io.IOException
Sets the non-stroking color and, if necessary, the non-stroking color space.- Parameters:
color
- Color in a specific color space.- Throws:
java.io.IOException
- If an IO error occurs while writing to the stream.
-
setNonStrokingColor
public void setNonStrokingColor(java.awt.Color color) throws java.io.IOException
Set the non-stroking color using an AWT color. Conversion uses the default sRGB color space.- Parameters:
color
- The color to set.- Throws:
java.io.IOException
- If an IO error occurs while writing to the stream.
-
setNonStrokingColor
@Deprecated public void setNonStrokingColor(float[] components) throws java.io.IOException
Deprecated.UsesetNonStrokingColor(PDColor)
instead.Set the color components of current non-stroking color space.- Parameters:
components
- The components to set for the current color.- Throws:
java.io.IOException
- If there is an error while writing to the stream.
-
setNonStrokingColor
public void setNonStrokingColor(float r, float g, float b) throws java.io.IOException
Set 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:
java.io.IOException
- If an IO error occurs while writing to the stream.java.lang.IllegalArgumentException
- If the parameters are invalid.
-
setNonStrokingColor
@Deprecated public void setNonStrokingColor(int r, int g, int b) throws java.io.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:
java.io.IOException
- If an IO error occurs while writing to the stream.java.lang.IllegalArgumentException
- If the parameters are invalid.
-
setNonStrokingColor
public void setNonStrokingColor(int c, int m, int y, int k) throws java.io.IOException
Set 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:
java.io.IOException
- If an IO error occurs while writing to the stream.java.lang.IllegalArgumentException
- If the parameters are invalid.
-
setNonStrokingColor
@Deprecated public void setNonStrokingColor(double c, double m, double y, double k) throws java.io.IOException
Deprecated.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:
java.io.IOException
- If an IO error occurs while writing to the stream.
-
setNonStrokingColor
public void setNonStrokingColor(float c, float m, float y, float k) throws java.io.IOException
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:
java.io.IOException
- If an IO error occurs while writing to the stream.
-
setNonStrokingColor
public void setNonStrokingColor(int g) throws java.io.IOException
Deprecated.Set the non-stroking color in the DeviceGray color space. Range is 0..255.- Parameters:
g
- The gray value.- Throws:
java.io.IOException
- If an IO error occurs while writing to the stream.java.lang.IllegalArgumentException
- If the parameter is invalid.
-
setNonStrokingColor
@Deprecated public void setNonStrokingColor(double g) throws java.io.IOException
Deprecated.Set the non-stroking color in the DeviceGray color space. Range is 0..1.- Parameters:
g
- The gray value.- Throws:
java.io.IOException
- If an IO error occurs while writing to the stream.java.lang.IllegalArgumentException
- If the parameter is invalid.
-
setNonStrokingColor
public void setNonStrokingColor(float g) throws java.io.IOException
Set the non-stroking color in the DeviceGray color space. Range is 0..1.- Parameters:
g
- The gray value.- Throws:
java.io.IOException
- If an IO error occurs while writing to the stream.java.lang.IllegalArgumentException
- If the parameter is invalid.
-
addRect
public void addRect(float x, float y, float width, float height) throws java.io.IOException
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:
java.io.IOException
- If the content stream could not be written.java.lang.IllegalStateException
- If the method was called within a text block.
-
fillRect
@Deprecated public void fillRect(float x, float y, float width, float height) throws java.io.IOException
Deprecated.UseaddRect(float, float, float, float)
followed byfill()
instead.Fill a rectangle on the page using the current non stroking color.- 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:
java.io.IOException
- If there is an error while drawing on the screen.java.lang.IllegalStateException
- If the method was called within a text block.
-
addBezier312
@Deprecated public void addBezier312(float x1, float y1, float x2, float y2, float x3, float y3) throws java.io.IOException
Deprecated.UsecurveTo(float, float, float, float, float, float)
instead.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:
java.io.IOException
- If there is an error while adding the .
-
curveTo
public void curveTo(float x1, float y1, float x2, float y2, float x3, float y3) throws java.io.IOException
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:
java.io.IOException
- If the content stream could not be written.java.lang.IllegalStateException
- If the method was called within a text block.
-
addBezier32
@Deprecated public void addBezier32(float x2, float y2, float x3, float y3) throws java.io.IOException
Deprecated.UsecurveTo2(float, float, float, float)
instead.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:
java.io.IOException
- If there is an error while adding the .
-
curveTo2
public void curveTo2(float x2, float y2, float x3, float y3) throws java.io.IOException
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:
java.lang.IllegalStateException
- If the method was called within a text block.java.io.IOException
- If the content stream could not be written.
-
addBezier31
@Deprecated public void addBezier31(float x1, float y1, float x3, float y3) throws java.io.IOException
Deprecated.UsecurveTo1(float, float, float, float)
instead.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:
java.io.IOException
- If there is an error while adding the .
-
curveTo1
public void curveTo1(float x1, float y1, float x3, float y3) throws java.io.IOException
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:
java.io.IOException
- If the content stream could not be written.java.lang.IllegalStateException
- If the method was called within a text block.
-
moveTo
public void moveTo(float x, float y) throws java.io.IOException
Move the current position to the given coordinates.- Parameters:
x
- The x coordinate.y
- The y coordinate.- Throws:
java.io.IOException
- If the content stream could not be written.java.lang.IllegalStateException
- If the method was called within a text block.
-
lineTo
public void lineTo(float x, float y) throws java.io.IOException
Draw a line from the current position to the given coordinates.- Parameters:
x
- The x coordinate.y
- The y coordinate.- Throws:
java.io.IOException
- If the content stream could not be written.java.lang.IllegalStateException
- If the method was called within a text block.
-
addLine
@Deprecated public void addLine(float xStart, float yStart, float xEnd, float yEnd) throws java.io.IOException
Deprecated.Usemoveto(xStart,yStart)
followed bylineTo(xEnd,yEnd)
.add a line to the current path.- Parameters:
xStart
- The start x coordinate.yStart
- The start y coordinate.xEnd
- The end x coordinate.yEnd
- The end y coordinate.- Throws:
java.io.IOException
- If there is an error while adding the line.java.lang.IllegalStateException
- If the method was called within a text block.
-
drawLine
@Deprecated public void drawLine(float xStart, float yStart, float xEnd, float yEnd) throws java.io.IOException
Deprecated.Draw a line on the page using the current stroking color and the current line width.- Parameters:
xStart
- The start x coordinate.yStart
- The start y coordinate.xEnd
- The end x coordinate.yEnd
- The end y coordinate.- Throws:
java.io.IOException
- If there is an error while drawing on the screen.java.lang.IllegalStateException
- If the method was called within a text block.
-
addPolygon
@Deprecated public void addPolygon(float[] x, float[] y) throws java.io.IOException
Deprecated.UsemoveTo(float, float)
andlineTo(float, float)
methods instead.Add a polygon to the current path.- Parameters:
x
- x coordinate of each pointsy
- y coordinate of each points- Throws:
java.io.IOException
- If there is an error while drawing on the screen.java.lang.IllegalStateException
- If the method was called within a text block.java.lang.IllegalArgumentException
- If the two arrays have different lengths.
-
drawPolygon
@Deprecated public void drawPolygon(float[] x, float[] y) throws java.io.IOException
Deprecated.UsemoveTo(float, float)
andlineTo(float, float)
methods instead.Draw a polygon on the page using the current stroking color.- Parameters:
x
- x coordinate of each pointsy
- y coordinate of each points- Throws:
java.io.IOException
- If there is an error while drawing on the screen.java.lang.IllegalStateException
- If the method was called within a text block.
-
fillPolygon
@Deprecated public void fillPolygon(float[] x, float[] y) throws java.io.IOException
Deprecated.UsemoveTo(float, float)
andlineTo(float, float)
methods instead.Draw and fill a polygon on the page using the current stroking / non stroking colors.- Parameters:
x
- x coordinate of each pointsy
- y coordinate of each points- Throws:
java.io.IOException
- If there is an error while drawing on the screen.java.lang.IllegalStateException
- If the method was called within a text block.
-
stroke
public void stroke() throws java.io.IOException
Stroke the path.- Throws:
java.io.IOException
- If the content stream could not be writtenjava.lang.IllegalStateException
- If the method was called within a text block.
-
closeAndStroke
public void closeAndStroke() throws java.io.IOException
Close and stroke the path.- Throws:
java.io.IOException
- If the content stream could not be writtenjava.lang.IllegalStateException
- If the method was called within a text block.
-
fill
@Deprecated public void fill(int windingRule) throws java.io.IOException
Deprecated.Usefill()
orfillEvenOdd()
instead.Fill the path.- Parameters:
windingRule
- the winding rule to be used for filling- Throws:
java.io.IOException
- If the content stream could not be writtenjava.lang.IllegalArgumentException
- If the parameter is not a valid winding rule.
-
fill
public void fill() throws java.io.IOException
Fills the path using the nonzero winding number rule.- Throws:
java.io.IOException
- If the content stream could not be writtenjava.lang.IllegalStateException
- If the method was called within a text block.
-
fillEvenOdd
public void fillEvenOdd() throws java.io.IOException
Fills the path using the even-odd winding rule.- Throws:
java.io.IOException
- If the content stream could not be writtenjava.lang.IllegalStateException
- If the method was called within a text block.
-
fillAndStroke
public void fillAndStroke() throws java.io.IOException
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:
java.io.IOException
- If the content stream could not be writtenjava.lang.IllegalStateException
- If the method was called within a text block.
-
fillAndStrokeEvenOdd
public void fillAndStrokeEvenOdd() throws java.io.IOException
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:
java.io.IOException
- If the content stream could not be writtenjava.lang.IllegalStateException
- If the method was called within a text block.
-
closeAndFillAndStroke
public void closeAndFillAndStroke() throws java.io.IOException
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:
java.io.IOException
- If the content stream could not be writtenjava.lang.IllegalStateException
- If the method was called within a text block.
-
closeAndFillAndStrokeEvenOdd
public void closeAndFillAndStrokeEvenOdd() throws java.io.IOException
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:
java.io.IOException
- If the content stream could not be writtenjava.lang.IllegalStateException
- If the method was called within a text block.
-
shadingFill
public void shadingFill(PDShading shading) throws java.io.IOException
Fills the clipping area with the given shading.- Parameters:
shading
- Shading resource- Throws:
java.io.IOException
- If the content stream could not be writtenjava.lang.IllegalStateException
- If the method was called within a text block.
-
closeSubPath
@Deprecated public void closeSubPath() throws java.io.IOException
Deprecated.UseclosePath()
instead.Closes the current subpath.- Throws:
java.io.IOException
- If the content stream could not be written
-
closePath
public void closePath() throws java.io.IOException
Closes the current subpath.- Throws:
java.io.IOException
- If the content stream could not be writtenjava.lang.IllegalStateException
- If the method was called within a text block.
-
clipPath
@Deprecated public void clipPath(int windingRule) throws java.io.IOException
Deprecated.Useclip()
orclipEvenOdd()
instead.Clip path.- Parameters:
windingRule
- the winding rule to be used for clipping- Throws:
java.io.IOException
- If there is an error while clipping the path.java.lang.IllegalStateException
- If the method was called within a text block.
-
clip
public void clip() throws java.io.IOException
Intersects the current clipping path with the current path, using the nonzero rule.- Throws:
java.io.IOException
- If the content stream could not be writtenjava.lang.IllegalStateException
- If the method was called within a text block.
-
clipEvenOdd
public void clipEvenOdd() throws java.io.IOException
Intersects the current clipping path with the current path, using the even-odd rule.- Throws:
java.io.IOException
- If the content stream could not be writtenjava.lang.IllegalStateException
- If the method was called within a text block.
-
setLineWidth
public void setLineWidth(float lineWidth) throws java.io.IOException
Set line width to the given value.- Parameters:
lineWidth
- The width which is used for drawing.- Throws:
java.io.IOException
- If the content stream could not be writtenjava.lang.IllegalStateException
- If the method was called within a text block.
-
setLineJoinStyle
public void setLineJoinStyle(int lineJoinStyle) throws java.io.IOException
Set the line join style.- Parameters:
lineJoinStyle
- 0 for miter join, 1 for round join, and 2 for bevel join.- Throws:
java.io.IOException
- If the content stream could not be written.java.lang.IllegalStateException
- If the method was called within a text block.java.lang.IllegalArgumentException
- If the parameter is not a valid line join style.
-
setLineCapStyle
public void setLineCapStyle(int lineCapStyle) throws java.io.IOException
Set the line cap style.- Parameters:
lineCapStyle
- 0 for butt cap, 1 for round cap, and 2 for projecting square cap.- Throws:
java.io.IOException
- If the content stream could not be written.java.lang.IllegalStateException
- If the method was called within a text block.java.lang.IllegalArgumentException
- If the parameter is not a valid line cap style.
-
setLineDashPattern
public void setLineDashPattern(float[] pattern, float phase) throws java.io.IOException
Set the line dash pattern.- Parameters:
pattern
- The pattern arrayphase
- The phase of the pattern- Throws:
java.io.IOException
- If the content stream could not be written.java.lang.IllegalStateException
- If the method was called within a text block.
-
setMiterLimit
public void setMiterLimit(float miterLimit) throws java.io.IOException
Set the miter limit.- Parameters:
miterLimit
- the new miter limit.- Throws:
java.io.IOException
- If the content stream could not be written.
-
beginMarkedContentSequence
@Deprecated public void beginMarkedContentSequence(COSName tag) throws java.io.IOException
Deprecated.UsebeginMarkedContent(org.apache.pdfbox.cos.COSName)
instead.Begin a marked content sequence.- Parameters:
tag
- the tag- Throws:
java.io.IOException
- if an I/O error occurs
-
beginMarkedContent
public void beginMarkedContent(COSName tag) throws java.io.IOException
Begin a marked content sequence.- Parameters:
tag
- the tag- Throws:
java.io.IOException
- If the content stream could not be written
-
beginMarkedContentSequence
@Deprecated public void beginMarkedContentSequence(COSName tag, COSName propsName) throws java.io.IOException
Deprecated.UsebeginMarkedContent(COSName, PDPropertyList)
instead.Begin a marked content sequence with a reference to an entry in the page resources' Properties dictionary.- Parameters:
tag
- the tagpropsName
- the properties reference- Throws:
java.io.IOException
- if an I/O error occurs
-
beginMarkedContent
public void beginMarkedContent(COSName tag, PDPropertyList propertyList) throws java.io.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:
java.io.IOException
- If the content stream could not be written
-
endMarkedContentSequence
@Deprecated public void endMarkedContentSequence() throws java.io.IOException
Deprecated.UseendMarkedContent()
instead.End a marked content sequence.- Throws:
java.io.IOException
- If the content stream could not be written
-
endMarkedContent
public void endMarkedContent() throws java.io.IOException
End a marked content sequence.- Throws:
java.io.IOException
- If the content stream could not be written
-
appendRawCommands
@Deprecated public void appendRawCommands(java.lang.String commands) throws java.io.IOException
Deprecated.Usage of this method is discouraged.This will append raw commands to the content stream.- Parameters:
commands
- The commands to append to the stream.- Throws:
java.io.IOException
- If an error occurs while writing to the stream.
-
appendRawCommands
@Deprecated public void appendRawCommands(byte[] commands) throws java.io.IOException
Deprecated.Usage of this method is discouraged.This will append raw commands to the content stream.- Parameters:
commands
- The commands to append to the stream.- Throws:
java.io.IOException
- If an error occurs while writing to the stream.
-
appendRawCommands
@Deprecated public void appendRawCommands(int data) throws java.io.IOException
Deprecated.Usage of this method is discouraged.This will append raw commands to the content stream.- Parameters:
data
- Append a raw byte to the stream.- Throws:
java.io.IOException
- If an error occurs while writing to the stream.
-
appendRawCommands
@Deprecated public void appendRawCommands(double data) throws java.io.IOException
Deprecated.Usage of this method is discouraged.This will append raw commands to the content stream.- Parameters:
data
- Append a formatted double value to the stream.- Throws:
java.io.IOException
- If an error occurs while writing to the stream.
-
appendRawCommands
@Deprecated public void appendRawCommands(float data) throws java.io.IOException
Deprecated.Usage of this method is discouraged.This will append raw commands to the content stream.- Parameters:
data
- Append a formatted float value to the stream.- Throws:
java.io.IOException
- If an error occurs while writing to the stream.
-
appendCOSName
@Deprecated public void appendCOSName(COSName name) throws java.io.IOException
Deprecated.Usage of this method is discouraged.This will append aCOSName
to the content stream.- Parameters:
name
- the name- Throws:
java.io.IOException
- If an error occurs while writing to the stream.
-
setGraphicsStateParameters
public void setGraphicsStateParameters(PDExtendedGraphicsState state) throws java.io.IOException
Set an extended graphics state.- Parameters:
state
- The extended graphics state.- Throws:
java.io.IOException
- If the content stream could not be written.
-
addComment
public void addComment(java.lang.String comment) throws java.io.IOException
Write a comment line.- Parameters:
comment
- the comment to be added to the content stream.- Throws:
java.io.IOException
- If the content stream could not be written.java.lang.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 java.io.IOException
Writes a real number to the content stream.- Parameters:
real
- the float value to be added to the content stream.- Throws:
java.io.IOException
- if something went wrongjava.lang.IllegalArgumentException
- if the parameter is not a finite number
-
writeOperand
private void writeOperand(int integer) throws java.io.IOException
Writes an integer number to the content stream.- Throws:
java.io.IOException
-
writeOperand
private void writeOperand(COSName name) throws java.io.IOException
Writes a COSName to the content stream.- Throws:
java.io.IOException
-
writeOperator
private void writeOperator(java.lang.String text) throws java.io.IOException
Writes a string to the content stream as ASCII.- Throws:
java.io.IOException
-
write
private void write(java.lang.String text) throws java.io.IOException
Writes a string to the content stream as ASCII.- Throws:
java.io.IOException
-
writeLine
private void writeLine() throws java.io.IOException
Writes a newline to the content stream as ASCII.- Throws:
java.io.IOException
-
writeBytes
private void writeBytes(byte[] data) throws java.io.IOException
Writes binary data to the content stream.- Throws:
java.io.IOException
-
writeAffineTransform
private void writeAffineTransform(java.awt.geom.AffineTransform transform) throws java.io.IOException
Writes an AffineTransform to the content stream as an array.- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException
Close the content stream. This must be called when you are done with this object.- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Throws:
java.io.IOException
- If the underlying stream has a problem being written to.
-
isOutside255Interval
private boolean isOutside255Interval(int val)
-
isOutsideOneInterval
private boolean isOutsideOneInterval(double val)
-
setStrokingColorSpaceStack
private void setStrokingColorSpaceStack(PDColorSpace colorSpace)
-
setNonStrokingColorSpaceStack
private void setNonStrokingColorSpaceStack(PDColorSpace colorSpace)
-
setRenderingMode
public void setRenderingMode(RenderingMode rm) throws java.io.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:
java.io.IOException
- If the content stream could not be written.
-
setCharacterSpacing
public void setCharacterSpacing(float spacing) throws java.io.IOException
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:
java.io.IOException
- If the content stream could not be written.
-
setWordSpacing
public void setWordSpacing(float spacing) throws java.io.IOException
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:
java.io.IOException
- If the content stream could not be written.
-
setHorizontalScaling
public void setHorizontalScaling(float scale) throws java.io.IOException
Set the horizontal scaling to scale / 100.- Parameters:
scale
- number specifying the percentage of the normal width. Default value: 100 (normal width).- Throws:
java.io.IOException
- If the content stream could not be written.
-
setTextRise
public void setTextRise(float rise) throws java.io.IOException
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:
java.io.IOException
-
-