Class PdfContentByte
- Direct Known Subclasses:
PdfCopy.StampContent
,PdfTemplate
,StampContent
,Type3Glyph
PdfContentByte
is an object containing the user positioned
text and graphic contents of a page. It knows how to apply the proper font encoding.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static class
This class keeps the graphic state of the current page -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
The alignment is centerstatic final int
The alignment is leftstatic final int
The alignment is rightprotected ByteBuffer
This is the actual contentprivate boolean
private int
private int
The list were we save/restore the layer depthprivate Point2D
static final int
A possible line cap valuestatic final int
A possible line cap valuestatic final int
A possible line cap valuestatic final int
A possible line join valuestatic final int
A possible line join valuestatic final int
A possible line join valueprivate int
(package private) static final float
protected PdfDocument
This is the PdfDocumentprotected int
The separator between commands.protected PdfContentByte.GraphicState
This is the GraphicState in useprotected List
<PdfContentByte.GraphicState> The list were we save/restore the statestatic final int
A possible text rendering valuestatic final int
A possible text rendering valuestatic final int
A possible text rendering valuestatic final int
A possible text rendering valuestatic final int
A possible text rendering valuestatic final int
A possible text rendering valuestatic final int
A possible text rendering valuestatic final int
A possible text rendering valueprivate static final float[]
protected PdfWriter
This is the writer -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(PdfContentByte other) Adds the content of anotherPdfContent
-object to this object.(package private) void
addAnnotation
(PdfAnnotation annot) void
Adds anImage
to the page.void
Adds anImage
to the page.void
Adds anImage
to the page.void
Adds anImage
to the page.void
addOutline
(PdfOutline outline, String name) Adds a named outline to the document.void
addPSXObject
(PdfPSXObject psobject) Adds a PostScript XObject to this content.void
addTemplate
(PdfTemplate template, double a, double b, double c, double d, double e, double f) Adds a template to this content using double matrices.void
addTemplate
(PdfTemplate template, float x, float y) Adds a template to this content.void
addTemplate
(PdfTemplate template, float a, float b, float c, float d, float e, float f) Adds a template to this content.(package private) void
addTemplateReference
(PdfIndirectReference template, PdfName name, float a, float b, float c, float d, float e, float f) void
arc
(float x1, float y1, float x2, float y2, float startAng, float extent) Draws a partial ellipse inscribed within the rectangle x1,y1,x2,y2, starting at startAng degrees and covering extent degrees.void
beginLayer
(PdfOCG layer) Begins a graphic block whose visibility is controlled by thelayer
.private void
beginLayer2
(PdfOCG layer) void
This is just a shorthand tobeginMarkedContentSequence(tag, null, false)
.void
beginMarkedContentSequence
(PdfName tag, PdfDictionary property, boolean inline) Begins a marked content sequence.void
Begins a marked content sequence.void
beginMarkedContentSequence
(PdfStructureElement struc, PdfDictionary dict) void
Starts the writing of text.static List
<float[]> bezierArc
(float x1, float y1, float x2, float y2, float startAng, float extent) Generates an array of bezier curves to draw an arc.(package private) void
Throws an error if it is a pattern.protected void
Check if we have a valid PdfWriter.void
circle
(float x, float y, float r) Draws a circle.void
clip()
Modify the current clipping path by intersecting it with the current path, using the nonzero winding number rule to determine which regions lie inside the clipping path.void
Closes the current subpath by appending a straight line segment from the current point to the starting point of the subpath.void
Closes the path, fills it using the even-odd rule to determine the region to fill and strokes it.void
Closes the path, fills it using the non-zero winding number rule to determine the region to fill and strokes it.void
Closes the path and strokes it.private boolean
compareColors
(Color c1, Color c2) void
concatCTM
(float a, float b, float c, float d, float e, float f) Concatenate a matrix to the current transformation matrix.createAppearance
(float width, float height) Creates a new appearance to be used with form fields.(package private) PdfAppearance
createAppearance
(float width, float height, PdfName forcedName) createGraphics
(float width, float height) Gets aGraphics2D
to write on.createGraphics
(float width, float height, boolean convertImagesToJPEG, float quality) Gets aGraphics2D
to write on.createGraphics
(float width, float height, FontMapper fontMapper) Gets aGraphics2D
to write on.createGraphics
(float width, float height, FontMapper fontMapper, boolean convertImagesToJPEG, float quality) Gets aGraphics2D
to write on.createGraphicsShapes
(float width, float height) Gets aGraphics2D
to write on.createGraphicsShapes
(float width, float height, boolean convertImagesToJPEG, float quality) Gets aGraphics2D
to print on.createPattern
(float width, float height) Create a new colored tiling pattern.createPattern
(float width, float height, float xstep, float ystep) Create a new colored tiling pattern.createPattern
(float width, float height, float xstep, float ystep, Color color) Create a new uncolored tiling pattern.createPattern
(float width, float height, Color color) Create a new uncolored tiling pattern.createPrinterGraphics
(float width, float height, boolean convertImagesToJPEG, float quality, PrinterJob printerJob) Gets aGraphics2D
to print on.createPrinterGraphics
(float width, float height, FontMapper fontMapper, boolean convertImagesToJPEG, float quality, PrinterJob printerJob) Gets aGraphics2D
to print on.createPrinterGraphics
(float width, float height, FontMapper fontMapper, PrinterJob printerJob) Gets aGraphics2D
to print on.createPrinterGraphics
(float width, float height, PrinterJob printerJob) Gets aGraphics2D
to print on.createPrinterGraphicsShapes
(float width, float height, boolean convertImagesToJPEG, float quality, PrinterJob printerJob) Gets aGraphics2D
to print on.createPrinterGraphicsShapes
(float width, float height, PrinterJob printerJob) Gets aGraphics2D
to print on.createTemplate
(float width, float height) Creates a new template.(package private) PdfTemplate
createTemplate
(float width, float height, PdfName forcedName) void
curveFromTo
(float x1, float y1, float x3, float y3) Appends a Bêzier curve to the path, starting from the current point.void
curveTo
(float x2, float y2, float x3, float y3) Appends a Bêzier curve to the path, starting from the current point.void
curveTo
(float x1, float y1, float x2, float y2, float x3, float y3) Appends a Bêzier curve to the path, starting from the current point.void
drawButton
(float llx, float lly, float urx, float ury, String text, BaseFont bf, float size) Draws a button.void
drawRadioField
(float llx, float lly, float urx, float ury, boolean on) Draws a TextField.void
drawTextField
(float llx, float lly, float urx, float ury) Draws a TextField.void
ellipse
(float x1, float y1, float x2, float y2) Draws an ellipse inscribed within the rectangle x1,y1,x2,y2.void
endLayer()
Ends a layer controlled graphic block.void
Ends a marked content sequencevoid
endText()
Ends the writing of text and makes the current font invalid.void
eoClip()
Modify the current clipping path by intersecting it with the current path, using the even-odd rule to determine which regions lie inside the clipping path.void
eoFill()
Fills the path, using the even-odd rule to determine the region to fill.void
Fills the path, using the even-odd rule to determine the region to fill and strokes it.(package private) static byte[]
escapeString
(byte[] b) Escapes abyte
array according to the PDF conventions.(package private) static void
escapeString
(byte[] b, ByteBuffer content) Escapes abyte
array according to the PDF conventions.void
fill()
Fills the path, using the non-zero winding number rule to determine the region to fill.void
Fills the path using the non-zero winding number rule to determine the region to fill and strokes it.float
Gets the current character spacing.Gets a duplicate of thisPdfContentByte
.float
getEffectiveStringWidth
(String text, boolean kerned) Computes the width of the given string taking in account the current values of "Character spacing", "Word Spacing" and "Horizontal Scaling".float
Gets the current character spacing.Gets the internal buffer.static PdfTextArray
getKernArray
(String text, BaseFont font) Constructs a kern array for a text in a certain fontfloat
Gets the current text leading.(package private) PageResources
Gets thePdfDocument
in use by this object.Gets thePdfWriter
in use by this object.Gets the root outline.float
Gets the current word spacing.float
getXTLM()
Gets the x position of the text line matrix.float
getYTLM()
Gets the y position of the text line matrix.private void
HelperCMYK
(float cyan, float magenta, float yellow, float black) Helper to validate and write the CMYK color components.private void
HelperCMYK
(int cyan, int magenta, int yellow, int black) Helper to validate and write the CMYK color components.private void
HelperRGB
(float red, float green, float blue) Helper to validate and write the RGB color componentsprivate void
HelperRGB
(int red, int green, int blue) Helper to validate and write the RGB color componentsvoid
lineTo
(float x, float y) Appends a straight line segment from the current point (x, y).boolean
localDestination
(String name, PdfDestination destination) The local destination to where a local goto with the same name will jump.void
Implements a link to other part of the document.void
moveText
(float x, float y) Moves to the start of the next line, offset from the start of the current line.(package private) void
moveTextBasic
(float x, float y) Moves to the start of the next line, offset from the start of the current line.void
moveTextWithLeading
(float x, float y) Moves to the start of the next line, offset from the start of the current line.void
moveTo
(float x, float y) Move the current point (x, y), omitting any connecting line segment.void
newlineShowText
(float wordSpacing, float charSpacing, String text) Moves to the next line and shows text string, using the given values of the character and word spacing parameters.void
newlineShowText
(String text) Moves to the next line and showstext
.void
Moves to the start of the next line.void
newPath()
Ends the path without filling or stroking it.(package private) void
outputColorNumbers
(Color color, float tint) Outputs the color values to the content.void
paintShading
(PdfShading shading) Paints using a shading object.void
paintShading
(PdfShadingPattern shading) Paints using a shading pattern.void
rectangle
(float x, float y, float w, float h) Adds a rectangle to the current path.void
Adds a border (complete or partially) to the current path..void
remoteGoto
(String filename, int page, float llx, float lly, float urx, float ury) Implements a link to another document.void
remoteGoto
(String filename, String name, float llx, float lly, float urx, float ury) Implements a link to another document.void
reset()
Makes thisPdfContentByte
empty.void
reset
(boolean validateContent) Makes thisPdfContentByte
empty.void
Changes the current color for filling paths to black.void
Changes the current color for stroking paths to black.void
Changes the current gray tint for filling paths to black.void
Changes the current gray tint for stroking paths to black.void
Changes the current color for filling paths to black.void
Changes the current color for stroking paths to black.void
Restores the graphic state.void
roundRectangle
(float x, float y, float w, float h, float r) Adds a round rectangle to the current path.void
Checks for any dangling state: Mismatched save/restore state, begin/end text, begin/end layer, or begin/end marked content sequence.private void
saveColorFill
(ExtendedColor extendedColor) private void
saveColorStroke
(ExtendedColor extendedColor) void
Saves the graphic state.void
Implements an action in an area.void
setCharacterSpacing
(float charSpace) Sets the character spacing parameter.void
setCMYKColorFill
(int cyan, int magenta, int yellow, int black) Changes the current color for filling paths (device dependent colors!).void
setCMYKColorFillF
(float cyan, float magenta, float yellow, float black) Changes the current color for filling paths (device dependent colors!).void
setCMYKColorFillF
(float cyan, float magenta, float yellow, float black, float alpha) void
setCMYKColorStroke
(int cyan, int magenta, int yellow, int black) Changes the current color for stroking paths (device dependent colors!).void
setCMYKColorStrokeF
(float cyan, float magenta, float yellow, float black) Changes the current color for stroking paths (device dependent colors!).void
setCMYKColorStrokeF
(float cyan, float magenta, float yellow, float black, float alpha) void
setColorFill
(PdfSpotColor sp, float tint) Sets the fill color to a spot color.void
setColorFill
(Color color) Sets the fill color.void
setColorStroke
(PdfSpotColor sp, float tint) Sets the stroke color to a spot color.void
setColorStroke
(Color color) Sets the stroke color.void
setDefaultColorspace
(PdfName name, PdfObject obj) Sets the default colorspace.void
setFlatness
(float flatness) Changes the Flatness.void
setFontAndSize
(BaseFont bf, float size) Set the font and the size for the subsequent text writing.void
setGrayFill
(float gray) Changes the currentgray tint for filling paths (device dependent colors!).void
setGrayFill
(float gray, float alpha) void
setGrayStroke
(float gray) Changes the currentgray tint for stroking paths (device dependent colors!).void
setGrayStroke
(float gray, float alpha) void
Sets the graphic statevoid
setHorizontalScaling
(float scale) Sets the horizontal scaling parameter.void
setLeading
(float leading) Sets the text leading parameter.void
setLineCap
(int style) Changes the Line cap style.void
setLineDash
(float phase) Changes the value of the line dash pattern.final void
setLineDash
(float[] array, float phase) Changes the value of the line dash pattern.void
setLineDash
(float unitsOn, float phase) Changes the value of the line dash pattern.void
setLineDash
(float unitsOn, float unitsOff, float phase) Changes the value of the line dash pattern.void
setLineJoin
(int style) Changes the Line join style.void
setLineWidth
(float w) Changes the line width.void
setLiteral
(char c) Outputs achar
directly to the content.void
setLiteral
(float n) Outputs afloat
directly to the content.void
setLiteral
(String s) Outputs aString
directly to the content.void
setMiterLimit
(float miterLimit) Changes the Miter limit.void
Sets the fill color to a pattern.void
setPatternFill
(PdfPatternPainter p, Color color) Sets the fill color to an uncolored pattern.void
setPatternFill
(PdfPatternPainter p, Color color, float tint) Sets the fill color to an uncolored pattern.void
Sets the stroke color to a pattern.void
setPatternStroke
(PdfPatternPainter p, Color color) Sets the stroke color to an uncolored pattern.void
setPatternStroke
(PdfPatternPainter p, Color color, float tint) Sets the stroke color to an uncolored pattern.void
setRGBColorFill
(int red, int green, int blue) Changes the current color for filling paths (device dependent colors!).void
setRGBColorFill
(int red, int green, int blue, int alpha) void
setRGBColorFillF
(float red, float green, float blue) Changes the current color for filling paths (device dependent colors!).void
setRGBColorFillF
(float red, float green, float blue, float alpha) void
setRGBColorStroke
(int red, int green, int blue) Changes the current color for stroking paths (device dependent colors!).void
setRGBColorStroke
(int red, int green, int blue, int alpha) void
setRGBColorStrokeF
(float red, float green, float blue) Changes the current color for stroking paths (device dependent colors!).void
setShadingFill
(PdfShadingPattern shading) Sets the shading fill pattern.void
setShadingStroke
(PdfShadingPattern shading) Sets the shading stroke patternvoid
setTextMatrix
(float x, float y) Changes the text matrix.void
setTextMatrix
(float a, float b, float c, float d, float x, float y) Changes the text matrix.void
setTextRenderingMode
(int rendering) Sets the text rendering parameter.void
setTextRise
(float rise) Sets the text rise parameter.void
setWordSpacing
(float wordSpace) Sets the word spacing parameter.void
showText
(PdfTextArray text) Show an array of text.void
showText
(GlyphVector glyphVector) Shows the glyphs inglyphVector
.void
showText
(GlyphVector glyphVector, int beginIndex, int endIndex) Shows theglyphVector
.void
Shows thetext
.private void
A helper to insert into the content stream thetext
converted to bytes according to the font's encoding.void
showTextAligned
(int alignment, String text, float x, float y, float rotation) Shows text right, left or center aligned with rotation.private void
showTextAligned
(int alignment, String text, float x, float y, float rotation, boolean kerned) void
showTextAlignedKerned
(int alignment, String text, float x, float y, float rotation) Shows text kerned right, left or center aligned with rotation.void
showTextBasic
(String text) Shows thetext
.void
showTextKerned
(String text) Shows thetext
kerned.(package private) int
size()
Gets the size of this content.void
stroke()
Strokes the path.byte[]
Returns the PDF representation of thisPdfContentByte
-object.toString()
Returns theString
representation of thisPdfContentByte
-object.void
Concatenates a transformation to the current transformation matrix.void
variableRectangle
(Rectangle rect) Adds a variable width border to the current path.
-
Field Details
-
ALIGN_CENTER
public static final int ALIGN_CENTERThe alignment is center- See Also:
-
ALIGN_LEFT
public static final int ALIGN_LEFTThe alignment is left- See Also:
-
ALIGN_RIGHT
public static final int ALIGN_RIGHTThe alignment is right- See Also:
-
LINE_CAP_BUTT
public static final int LINE_CAP_BUTTA possible line cap value- See Also:
-
LINE_CAP_ROUND
public static final int LINE_CAP_ROUNDA possible line cap value- See Also:
-
LINE_CAP_PROJECTING_SQUARE
public static final int LINE_CAP_PROJECTING_SQUAREA possible line cap value- See Also:
-
LINE_JOIN_MITER
public static final int LINE_JOIN_MITERA possible line join value- See Also:
-
LINE_JOIN_ROUND
public static final int LINE_JOIN_ROUNDA possible line join value- See Also:
-
LINE_JOIN_BEVEL
public static final int LINE_JOIN_BEVELA possible line join value- See Also:
-
TEXT_RENDER_MODE_FILL
public static final int TEXT_RENDER_MODE_FILLA possible text rendering value- See Also:
-
TEXT_RENDER_MODE_STROKE
public static final int TEXT_RENDER_MODE_STROKEA possible text rendering value- See Also:
-
TEXT_RENDER_MODE_FILL_STROKE
public static final int TEXT_RENDER_MODE_FILL_STROKEA possible text rendering value- See Also:
-
TEXT_RENDER_MODE_INVISIBLE
public static final int TEXT_RENDER_MODE_INVISIBLEA possible text rendering value- See Also:
-
TEXT_RENDER_MODE_FILL_CLIP
public static final int TEXT_RENDER_MODE_FILL_CLIPA possible text rendering value- See Also:
-
TEXT_RENDER_MODE_STROKE_CLIP
public static final int TEXT_RENDER_MODE_STROKE_CLIPA possible text rendering value- See Also:
-
TEXT_RENDER_MODE_FILL_STROKE_CLIP
public static final int TEXT_RENDER_MODE_FILL_STROKE_CLIPA possible text rendering value- See Also:
-
TEXT_RENDER_MODE_CLIP
public static final int TEXT_RENDER_MODE_CLIPA possible text rendering value- See Also:
-
MIN_FONT_SIZE
static final float MIN_FONT_SIZE- See Also:
-
unitRect
private static final float[] unitRect -
abrev
-
This is the actual content
-
writer
This is the writer -
pdf
This is the PdfDocument -
state
This is the GraphicState in use -
stateList
The list were we save/restore the state -
separator
protected int separatorThe separator between commands. -
layerDepth
The list were we save/restore the layer depth -
mcDepth
private int mcDepth -
inText
private boolean inText -
lastFillAlpha
private int lastFillAlpha -
lastStrokeAlpha
private int lastStrokeAlpha -
layoutPositionCorrection
-
-
Constructor Details
-
PdfContentByte
Constructs a newPdfContentByte
-object.- Parameters:
wr
- the writer associated to this content
-
-
Method Details
-
getKernArray
Constructs a kern array for a text in a certain font- Parameters:
text
- the textfont
- the font- Returns:
- a PdfTextArray
-
escapeString
static byte[] escapeString(byte[] b) Escapes abyte
array according to the PDF conventions.- Parameters:
b
- thebyte
array to escape- Returns:
- an escaped
byte
array
-
escapeString
Escapes abyte
array according to the PDF conventions.- Parameters:
b
- thebyte
array to escapecontent
- the content
-
bezierArc
public static List<float[]> bezierArc(float x1, float y1, float x2, float y2, float startAng, float extent) Generates an array of bezier curves to draw an arc.(x1, y1) and (x2, y2) are the corners of the enclosing rectangle. Angles, measured in degrees, start with 0 to the right (the positive X axis) and increase counter-clockwise. The arc extends from startAng to startAng+extent. I.e. startAng=0 and extent=180 yields an openside-down semi-circle.
The resulting coordinates are of the form float[]{x1,y1,x2,y2,x3,y3, x4,y4} such that the curve goes from (x1, y1) to (x4, y4) with (x2, y2) and (x3, y3) as their respective Bezier control points.
Note: this code was taken from ReportLab (www.reportlab.org), an excellent PDF generator for Python (BSD license: http://www.reportlab.org/devfaq.html#1.3 ).
- Parameters:
x1
- a corner of the enclosing rectangley1
- a corner of the enclosing rectanglex2
- a corner of the enclosing rectangley2
- a corner of the enclosing rectanglestartAng
- starting angle in degreesextent
- angle extent in degrees- Returns:
- a list of float[] with the bezier curves
-
toString
Returns theString
representation of thisPdfContentByte
-object. -
getInternalBuffer
Gets the internal buffer.- Returns:
- the internal buffer
-
toPdf
Returns the PDF representation of thisPdfContentByte
-object.- Parameters:
writer
- thePdfWriter
- Returns:
- a
byte
array with the representation
-
add
Adds the content of anotherPdfContent
-object to this object.- Parameters:
other
- anotherPdfByteContent
-object
-
getXTLM
public float getXTLM()Gets the x position of the text line matrix.- Returns:
- the x position of the text line matrix
-
getYTLM
public float getYTLM()Gets the y position of the text line matrix.- Returns:
- the y position of the text line matrix
-
getLeading
public float getLeading()Gets the current text leading.- Returns:
- the current text leading
-
setLeading
public void setLeading(float leading) Sets the text leading parameter.The leading parameter is measured in text space units. It specifies the vertical distance between the baselines of adjacent lines of text.
- Parameters:
leading
- the new leading
-
getCharacterSpacing
public float getCharacterSpacing()Gets the current character spacing.- Returns:
- the current character spacing
-
setCharacterSpacing
public void setCharacterSpacing(float charSpace) Sets the character spacing parameter.- Parameters:
charSpace
- a parameter
-
getWordSpacing
public float getWordSpacing()Gets the current word spacing.- Returns:
- the current word spacing
-
setWordSpacing
public void setWordSpacing(float wordSpace) Sets the word spacing parameter.- Parameters:
wordSpace
- a parameter
-
getHorizontalScaling
public float getHorizontalScaling()Gets the current character spacing.- Returns:
- the current character spacing
-
setHorizontalScaling
public void setHorizontalScaling(float scale) Sets the horizontal scaling parameter.- Parameters:
scale
- a parameter
-
setFlatness
public void setFlatness(float flatness) Changes the Flatness.Flatness sets the maximum permitted distance in device pixels between the mathematically correct path and an approximation constructed from straight line segments.
- Parameters:
flatness
- a value
-
setLineCap
public void setLineCap(int style) Changes the Line cap style.The line cap style specifies the shape to be used at the end of open subpaths when they are stroked.
Allowed values are LINE_CAP_BUTT, LINE_CAP_ROUND and LINE_CAP_PROJECTING_SQUARE.- Parameters:
style
- a value
-
setLineDash
public void setLineDash(float phase) Changes the value of the line dash pattern.The line dash pattern controls the pattern of dashes and gaps used to stroke paths. It is specified by an array and a phase. The array specifies the length of the alternating dashes and gaps. The phase specifies the distance into the dash pattern to start the dash.
- Parameters:
phase
- the value of the phase
-
setLineDash
public void setLineDash(float unitsOn, float phase) Changes the value of the line dash pattern.The line dash pattern controls the pattern of dashes and gaps used to stroke paths. It is specified by an array and a phase. The array specifies the length of the alternating dashes and gaps. The phase specifies the distance into the dash pattern to start the dash.
- Parameters:
unitsOn
- the number of units that must be 'on' (equals the number of units that must be 'off').phase
- the value of the phase
-
setLineDash
public void setLineDash(float unitsOn, float unitsOff, float phase) Changes the value of the line dash pattern.The line dash pattern controls the pattern of dashes and gaps used to stroke paths. It is specified by an array and a phase. The array specifies the length of the alternating dashes and gaps. The phase specifies the distance into the dash pattern to start the dash.
- Parameters:
unitsOn
- the number of units that must be 'on'unitsOff
- the number of units that must be 'off'phase
- the value of the phase
-
setLineDash
public final void setLineDash(float[] array, float phase) Changes the value of the line dash pattern.The line dash pattern controls the pattern of dashes and gaps used to stroke paths. It is specified by an array and a phase. The array specifies the length of the alternating dashes and gaps. The phase specifies the distance into the dash pattern to start the dash.
- Parameters:
array
- length of the alternating dashes and gapsphase
- the value of the phase
-
setLineJoin
public void setLineJoin(int style) Changes the Line join style.The line join style specifies the shape to be used at the corners of paths that are stroked.
Allowed values are LINE_JOIN_MITER (Miter joins), LINE_JOIN_ROUND (Round joins) and LINE_JOIN_BEVEL (Bevel joins).- Parameters:
style
- a value
-
setLineWidth
public void setLineWidth(float w) Changes the line width.The line width specifies the thickness of the line used to stroke a path and is measured in user space units.
- Parameters:
w
- a width
-
setMiterLimit
public void setMiterLimit(float miterLimit) Changes the Miter limit.When two line segments meet at a sharp angle and mitered joins have been specified as the line join style, it is possible for the miter to extend far beyond the thickness of the line stroking path. The miter limit imposes a maximum on the ratio of the miter length to the line witdh. When the limit is exceeded, the join is converted from a miter to a bevel.
- Parameters:
miterLimit
- a miter limit
-
clip
public void clip()Modify the current clipping path by intersecting it with the current path, using the nonzero winding number rule to determine which regions lie inside the clipping path. -
eoClip
public void eoClip()Modify the current clipping path by intersecting it with the current path, using the even-odd rule to determine which regions lie inside the clipping path. -
setGrayFill
public void setGrayFill(float gray) Changes the currentgray tint for filling paths (device dependent colors!).Sets the color space to DeviceGray (or the DefaultGray color space), and sets the gray tint to use for filling paths.
- Parameters:
gray
- a value between 0 (black) and 1 (white)
-
setGrayFill
public void setGrayFill(float gray, float alpha) -
resetGrayFill
public void resetGrayFill()Changes the current gray tint for filling paths to black. -
setGrayStroke
public void setGrayStroke(float gray) Changes the currentgray tint for stroking paths (device dependent colors!).Sets the color space to DeviceGray (or the DefaultGray color space), and sets the gray tint to use for stroking paths.
- Parameters:
gray
- a value between 0 (black) and 1 (white)
-
setGrayStroke
public void setGrayStroke(float gray, float alpha) -
resetGrayStroke
public void resetGrayStroke()Changes the current gray tint for stroking paths to black. -
HelperRGB
private void HelperRGB(int red, int green, int blue) Helper to validate and write the RGB color components- Parameters:
red
- the intensity of red. A value between 0 and 255green
- the intensity of green. A value between 0 and 255blue
- the intensity of blue. A value between 0 and 255
-
HelperRGB
private void HelperRGB(float red, float green, float blue) Helper to validate and write the RGB color components- Parameters:
red
- the intensity of red. A value between 0 and 1green
- the intensity of green. A value between 0 and 1blue
- the intensity of blue. A value between 0 and 1
-
setRGBColorFillF
public void setRGBColorFillF(float red, float green, float blue) Changes the current color for filling paths (device dependent colors!).Sets the color space to DeviceRGB (or the DefaultRGB color space), and sets the color to use for filling paths.
Following the PDF manual, each operand must be a number between 0 (minimum intensity) and 1 (maximum intensity).
- Parameters:
red
- the intensity of red. A value between 0 and 1green
- the intensity of green. A value between 0 and 1blue
- the intensity of blue. A value between 0 and 1
-
setRGBColorFillF
public void setRGBColorFillF(float red, float green, float blue, float alpha) -
resetRGBColorFill
public void resetRGBColorFill()Changes the current color for filling paths to black. Resetting using gray color to keep the backward compatibility. -
setRGBColorStrokeF
public void setRGBColorStrokeF(float red, float green, float blue) Changes the current color for stroking paths (device dependent colors!).Sets the color space to DeviceRGB (or the DefaultRGB color space), and sets the color to use for stroking paths.
Following the PDF manual, each operand must be a number between 0 (miniumum intensity) and 1 (maximum intensity).
- Parameters:
red
- the intensity of red. A value between 0 and 1green
- the intensity of green. A value between 0 and 1blue
- the intensity of blue. A value between 0 and 1
-
resetRGBColorStroke
public void resetRGBColorStroke()Changes the current color for stroking paths to black. Resetting using gray color to keep the backward compatibility. -
HelperCMYK
private void HelperCMYK(int cyan, int magenta, int yellow, int black) Helper to validate and write the CMYK color components.- Parameters:
cyan
- the intensity of cyan. A value between 0 and 255magenta
- the intensity of magenta. A value between 0 and 255yellow
- the intensity of yellow. A value between 0 and 255black
- the intensity of black. A value between 0 and 255
-
HelperCMYK
private void HelperCMYK(float cyan, float magenta, float yellow, float black) Helper to validate and write the CMYK color components.- Parameters:
cyan
- the intensity of cyan. A value between 0 and 1magenta
- the intensity of magenta. A value between 0 and 1yellow
- the intensity of yellow. A value between 0 and 1black
- the intensity of black. A value between 0 and 1
-
setCMYKColorFillF
public void setCMYKColorFillF(float cyan, float magenta, float yellow, float black) Changes the current color for filling paths (device dependent colors!).Sets the color space to DeviceCMYK (or the DefaultCMYK color space), and sets the color to use for filling paths.
Following the PDF manual, each operand must be a number between 0 (no ink) and 1 (maximum ink).
- Parameters:
cyan
- the intensity of cyan. A value between 0 and 1magenta
- the intensity of magenta. A value between 0 and 1yellow
- the intensity of yellow. A value between 0 and 1black
- the intensity of black. A value between 0 and 1
-
setCMYKColorFillF
public void setCMYKColorFillF(float cyan, float magenta, float yellow, float black, float alpha) -
resetCMYKColorFill
public void resetCMYKColorFill()Changes the current color for filling paths to black. -
setCMYKColorStrokeF
public void setCMYKColorStrokeF(float cyan, float magenta, float yellow, float black) Changes the current color for stroking paths (device dependent colors!).Sets the color space to DeviceCMYK (or the DefaultCMYK color space), and sets the color to use for stroking paths.
Following the PDF manual, each operand must be a number between 0 (miniumum intensity) and 1 (maximum intensity).
- Parameters:
cyan
- the intensity of cyan. A value between 0 and 1magenta
- the intensity of magenta. A value between 0 and 1yellow
- the intensity of yellow. A value between 0 and 1black
- the intensity of black. A value between 0 and 1
-
setCMYKColorStrokeF
public void setCMYKColorStrokeF(float cyan, float magenta, float yellow, float black, float alpha) -
resetCMYKColorStroke
public void resetCMYKColorStroke()Changes the current color for stroking paths to black. -
moveTo
public void moveTo(float x, float y) Move the current point (x, y), omitting any connecting line segment.- Parameters:
x
- new x-coordinatey
- new y-coordinate
-
lineTo
public void lineTo(float x, float y) Appends a straight line segment from the current point (x, y). The new current point is (x, y).- Parameters:
x
- new x-coordinatey
- new y-coordinate
-
curveTo
public void curveTo(float x1, float y1, float x2, float y2, float x3, float y3) Appends a Bêzier curve to the path, starting from the current point.- Parameters:
x1
- x-coordinate of the first control pointy1
- y-coordinate of the first control pointx2
- x-coordinate of the second control pointy2
- y-coordinate of the second control pointx3
- x-coordinate of the ending point (= new current point)y3
- y-coordinate of the ending point (= new current point)
-
curveTo
public void curveTo(float x2, float y2, float x3, float y3) Appends a Bêzier curve to the path, starting from the current point.- Parameters:
x2
- x-coordinate of the second control pointy2
- y-coordinate of the second control pointx3
- x-coordinate of the ending point (= new current point)y3
- y-coordinate of the ending point (= new current point)
-
curveFromTo
public void curveFromTo(float x1, float y1, float x3, float y3) Appends a Bêzier curve to the path, starting from the current point.- Parameters:
x1
- x-coordinate of the first control pointy1
- y-coordinate of the first control pointx3
- x-coordinate of the ending point (= new current point)y3
- y-coordinate of the ending point (= new current point)
-
circle
public void circle(float x, float y, float r) Draws a circle. The endpoint will (x+r, y).- Parameters:
x
- x center of circley
- y center of circler
- radius of circle
-
rectangle
public void rectangle(float x, float y, float w, float h) Adds a rectangle to the current path.- Parameters:
x
- x-coordinate of the starting pointy
- y-coordinate of the starting pointw
- widthh
- height
-
compareColors
-
variableRectangle
Adds a variable width border to the current path. Only use ifRectangle.isUseVariableBorders
= true.- Parameters:
rect
- aRectangle
-
rectangle
Adds a border (complete or partially) to the current path..- Parameters:
rectangle
- aRectangle
-
closePath
public void closePath()Closes the current subpath by appending a straight line segment from the current point to the starting point of the subpath. -
newPath
public void newPath()Ends the path without filling or stroking it. -
stroke
public void stroke()Strokes the path. -
closePathStroke
public void closePathStroke()Closes the path and strokes it. -
fill
public void fill()Fills the path, using the non-zero winding number rule to determine the region to fill. -
eoFill
public void eoFill()Fills the path, using the even-odd rule to determine the region to fill. -
fillStroke
public void fillStroke()Fills the path using the non-zero winding number rule to determine the region to fill and strokes it. -
closePathFillStroke
public void closePathFillStroke()Closes the path, fills it using the non-zero winding number rule to determine the region to fill and strokes it. -
eoFillStroke
public void eoFillStroke()Fills the path, using the even-odd rule to determine the region to fill and strokes it. -
closePathEoFillStroke
public void closePathEoFillStroke()Closes the path, fills it using the even-odd rule to determine the region to fill and strokes it. -
addImage
Adds anImage
to the page. TheImage
must have absolute positioning.- Parameters:
image
- theImage
object- Throws:
DocumentException
- if theImage
does not have absolute positioning
-
addImage
Adds anImage
to the page. TheImage
must have absolute positioning. The image can be placed inline.- Parameters:
image
- theImage
objectinlineImage
-true
to place this image inline,false
otherwise- Throws:
DocumentException
- if theImage
does not have absolute positioning
-
addImage
public void addImage(Image image, float a, float b, float c, float d, float e, float f) throws DocumentException Adds anImage
to the page. The positioning of theImage
is done with the transformation matrix. To position animage
at (x,y) use addImage(image, image_width, 0, 0, image_height, x, y).- Parameters:
image
- theImage
objecta
- an element of the transformation matrixb
- an element of the transformation matrixc
- an element of the transformation matrixd
- an element of the transformation matrixe
- an element of the transformation matrixf
- an element of the transformation matrix- Throws:
DocumentException
- on error
-
addImage
public void addImage(Image image, float a, float b, float c, float d, float e, float f, boolean inlineImage) throws DocumentException Adds anImage
to the page. The positioning of theImage
is done with the transformation matrix. To position animage
at (x,y) use addImage(image, image_width, 0, 0, image_height, x, y). The image can be placed inline.- Parameters:
image
- theImage
objecta
- an element of the transformation matrixb
- an element of the transformation matrixc
- an element of the transformation matrixd
- an element of the transformation matrixe
- an element of the transformation matrixf
- an element of the transformation matrixinlineImage
-true
to place this image inline,false
otherwise- Throws:
DocumentException
- on error
-
reset
public void reset()Makes thisPdfContentByte
empty. Callsreset( true )
-
reset
public void reset(boolean validateContent) Makes thisPdfContentByte
empty.- Parameters:
validateContent
- will callsanityCheck()
if true.- Since:
- 2.1.6
-
beginText
public void beginText()Starts the writing of text. -
endText
public void endText()Ends the writing of text and makes the current font invalid. -
saveState
public void saveState()Saves the graphic state.saveState
andrestoreState
must be balanced. -
restoreState
public void restoreState()Restores the graphic state.saveState
andrestoreState
must be balanced. -
setFontAndSize
Set the font and the size for the subsequent text writing.- Parameters:
bf
- the fontsize
- the font size in points
-
setTextRenderingMode
public void setTextRenderingMode(int rendering) Sets the text rendering parameter.- Parameters:
rendering
- a parameter
-
setTextRise
public void setTextRise(float rise) Sets the text rise parameter.This allows to write text in subscript or superscript mode.
- Parameters:
rise
- a parameter
-
showText2
A helper to insert into the content stream thetext
converted to bytes according to the font's encoding.- Parameters:
text
- the text to write
-
showText
Shows thetext
. If applicable, the LayoutProcessor is used- Parameters:
text
- the text to write
-
showTextBasic
Shows thetext
. LayoutProcessor is not used.- Parameters:
text
- the text to write
-
showText
Shows the glyphs inglyphVector
. Layout info inglyphVector
is ignored- Parameters:
glyphVector
- containing the glyphs to write
-
showText
Shows theglyphVector
. Layout info inglyphVector
is ignored- Parameters:
glyphVector
- containing the glyphs to writebeginIndex
- index of first glyphendIndex
- index of last glyph+1
-
showTextKerned
Shows thetext
kerned.- Parameters:
text
- the text to write
-
newlineShowText
Moves to the next line and showstext
.- Parameters:
text
- the text to write
-
newlineShowText
Moves to the next line and shows text string, using the given values of the character and word spacing parameters.- Parameters:
wordSpacing
- a parametercharSpacing
- a parametertext
- the text to write
-
setTextMatrix
public void setTextMatrix(float a, float b, float c, float d, float x, float y) Changes the text matrix.Remark: this operation also initializes the current point position.
- Parameters:
a
- operand 1,1 in the matrixb
- operand 1,2 in the matrixc
- operand 2,1 in the matrixd
- operand 2,2 in the matrixx
- operand 3,1 in the matrixy
- operand 3,2 in the matrix
-
setTextMatrix
public void setTextMatrix(float x, float y) Changes the text matrix. The first four parameters are {1,0,0,1}.Remark: this operation also initializes the current point position.
- Parameters:
x
- operand 3,1 in the matrixy
- operand 3,2 in the matrix
-
moveText
public void moveText(float x, float y) Moves to the start of the next line, offset from the start of the current line.- Parameters:
x
- x-coordinate of the new current pointy
- y-coordinate of the new current point
-
moveTextBasic
void moveTextBasic(float x, float y) Moves to the start of the next line, offset from the start of the current line.- Parameters:
x
- x-coordinate of the new current pointy
- y-coordinate of the new current point
-
moveTextWithLeading
public void moveTextWithLeading(float x, float y) Moves to the start of the next line, offset from the start of the current line.As a side effect, this sets the leading parameter in the text state.
- Parameters:
x
- offset of the new current pointy
- y-coordinate of the new current point
-
newlineText
public void newlineText()Moves to the start of the next line. -
size
int size()Gets the size of this content.- Returns:
- the size of the content
-
addOutline
Adds a named outline to the document.- Parameters:
outline
- the outlinename
- the name for the local destination
-
getRootOutline
Gets the root outline.- Returns:
- the root outline
-
getEffectiveStringWidth
Computes the width of the given string taking in account the current values of "Character spacing", "Word Spacing" and "Horizontal Scaling". The additional spacing is not computed for the last character of the string.- Parameters:
text
- the string to get width ofkerned
- the kerning option- Returns:
- the width
-
showTextAligned
Shows text right, left or center aligned with rotation.- Parameters:
alignment
- the alignment can be ALIGN_CENTER, ALIGN_RIGHT or ALIGN_LEFTtext
- the text to showx
- the x pivot positiony
- the y pivot positionrotation
- the rotation to be applied in degrees counterclockwise
-
showTextAligned
private void showTextAligned(int alignment, String text, float x, float y, float rotation, boolean kerned) -
showTextAlignedKerned
Shows text kerned right, left or center aligned with rotation.- Parameters:
alignment
- the alignment can be ALIGN_CENTER, ALIGN_RIGHT or ALIGN_LEFTtext
- the text to showx
- the x pivot positiony
- the y pivot positionrotation
- the rotation to be applied in degrees counterclockwise
-
concatCTM
public void concatCTM(float a, float b, float c, float d, float e, float f) Concatenate a matrix to the current transformation matrix.- Parameters:
a
- an element of the transformation matrixb
- an element of the transformation matrixc
- an element of the transformation matrixd
- an element of the transformation matrixe
- an element of the transformation matrixf
- an element of the transformation matrix
-
arc
public void arc(float x1, float y1, float x2, float y2, float startAng, float extent) Draws a partial ellipse inscribed within the rectangle x1,y1,x2,y2, starting at startAng degrees and covering extent degrees. Angles start with 0 to the right (+x) and increase counter-clockwise.- Parameters:
x1
- a corner of the enclosing rectangley1
- a corner of the enclosing rectanglex2
- a corner of the enclosing rectangley2
- a corner of the enclosing rectanglestartAng
- starting angle in degreesextent
- angle extent in degrees
-
ellipse
public void ellipse(float x1, float y1, float x2, float y2) Draws an ellipse inscribed within the rectangle x1,y1,x2,y2.- Parameters:
x1
- a corner of the enclosing rectangley1
- a corner of the enclosing rectanglex2
- a corner of the enclosing rectangley2
- a corner of the enclosing rectangle
-
createPattern
Create a new colored tiling pattern.- Parameters:
width
- the width of the patternheight
- the height of the patternxstep
- the desired horizontal spacing between pattern cells. May be either positive or negative, but not zero.ystep
- the desired vertical spacing between pattern cells. May be either positive or negative, but not zero.- Returns:
- the
PdfPatternPainter
where the pattern will be created
-
createPattern
Create a new colored tiling pattern. Variables xstep and ystep are set to the same values of width and height.- Parameters:
width
- the width of the patternheight
- the height of the pattern- Returns:
- the
PdfPatternPainter
where the pattern will be created
-
createPattern
public PdfPatternPainter createPattern(float width, float height, float xstep, float ystep, Color color) Create a new uncolored tiling pattern.- Parameters:
width
- the width of the patternheight
- the height of the patternxstep
- the desired horizontal spacing between pattern cells. May be either positive or negative, but not zero.ystep
- the desired vertical spacing between pattern cells. May be either positive or negative, but not zero.color
- the default color. Can benull
- Returns:
- the
PdfPatternPainter
where the pattern will be created
-
createPattern
Create a new uncolored tiling pattern. Variables xstep and ystep are set to the same values of width and height.- Parameters:
width
- the width of the patternheight
- the height of the patterncolor
- the default color. Can benull
- Returns:
- the
PdfPatternPainter
where the pattern will be created
-
createTemplate
Creates a new template.Creates a new template that is nothing more than a form XObject. This template can be included in this
PdfContentByte
or in another template. Templates are only written to the output when the document is closed permitting things like showing text in the first page that is only defined in the last page.- Parameters:
width
- the bounding box widthheight
- the bounding box height- Returns:
- the created template
-
createTemplate
-
createAppearance
Creates a new appearance to be used with form fields.- Parameters:
width
- the bounding box widthheight
- the bounding box height- Returns:
- the appearance created
-
createAppearance
-
addPSXObject
Adds a PostScript XObject to this content.- Parameters:
psobject
- the object
-
addTemplate
Adds a template to this content.- Parameters:
template
- the templatea
- an element of the transformation matrixb
- an element of the transformation matrixc
- an element of the transformation matrixd
- an element of the transformation matrixe
- an element of the transformation matrixf
- an element of the transformation matrix
-
addTemplateReference
void addTemplateReference(PdfIndirectReference template, PdfName name, float a, float b, float c, float d, float e, float f) -
addTemplate
Adds a template to this content.- Parameters:
template
- the templatex
- the x location of this templatey
- the y location of this template
-
addTemplate
public void addTemplate(PdfTemplate template, double a, double b, double c, double d, double e, double f) Adds a template to this content using double matrices.- Parameters:
template
- the templatea
- an element of the transformation matrixb
- an element of the transformation matrixc
- an element of the transformation matrixd
- an element of the transformation matrixe
- an element of the transformation matrixf
- an element of the transformation matrix
-
setCMYKColorFill
public void setCMYKColorFill(int cyan, int magenta, int yellow, int black) Changes the current color for filling paths (device dependent colors!).Sets the color space to DeviceCMYK (or the DefaultCMYK color space), and sets the color to use for filling paths.
This method is described in the 'Portable Document Format Reference Manual version 1.3' section 8.5.2.1 (page 331).
Following the PDF manual, each operand must be a number between 0 (no ink) and 1 (maximum ink). This method however accepts only integers between 0x00 and 0xFF.
- Parameters:
cyan
- the intensity of cyanmagenta
- the intensity of magentayellow
- the intensity of yellowblack
- the intensity of black
-
setCMYKColorStroke
public void setCMYKColorStroke(int cyan, int magenta, int yellow, int black) Changes the current color for stroking paths (device dependent colors!).Sets the color space to DeviceCMYK (or the DefaultCMYK color space), and sets the color to use for stroking paths.
This method is described in the 'Portable Document Format Reference Manual version 1.3' section 8.5.2.1 (page 331).
Following the PDF manual, each operand must be a number between 0 (minimum intensity) and 1 (maximum intensity). This method however accepts only integers between 0x00 and 0xFF.- Parameters:
cyan
- the intensity of redmagenta
- the intensity of greenyellow
- the intensity of blueblack
- the intensity of black
-
setRGBColorFill
public void setRGBColorFill(int red, int green, int blue) Changes the current color for filling paths (device dependent colors!).Sets the color space to DeviceRGB (or the DefaultRGB color space), and sets the color to use for filling paths.
This method is described in the 'Portable Document Format Reference Manual version 1.3' section 8.5.2.1 (page 331).
Following the PDF manual, each operand must be a number between 0 (minimum intensity) and 1 (maximum intensity). This method however accepts only integers between 0x00 and 0xFF.
- Parameters:
red
- the intensity of redgreen
- the intensity of greenblue
- the intensity of blue
-
setRGBColorFill
public void setRGBColorFill(int red, int green, int blue, int alpha) -
setRGBColorStroke
public void setRGBColorStroke(int red, int green, int blue) Changes the current color for stroking paths (device dependent colors!).Sets the color space to DeviceRGB (or the DefaultRGB color space), and sets the color to use for stroking paths.
This method is described in the 'Portable Document Format Reference Manual version 1.3' section 8.5.2.1 (page 331).
Following the PDF manual, each operand must be a number between 0 (minimum intensity) and 1 (maximum intensity). This method however accepts only integers between 0x00 and 0xFF.- Parameters:
red
- the intensity of redgreen
- the intensity of greenblue
- the intensity of blue
-
setRGBColorStroke
public void setRGBColorStroke(int red, int green, int blue, int alpha) -
setColorStroke
Sets the stroke color.color
can be anExtendedColor
.- Parameters:
color
- the color
-
saveColorStroke
-
setColorFill
Sets the fill color.color
can be anExtendedColor
.- Parameters:
color
- the color
-
saveColorFill
-
setColorFill
Sets the fill color to a spot color.- Parameters:
sp
- the spot colortint
- the tint for the spot color. 0 is no color and 1 is 100% color
-
setColorStroke
Sets the stroke color to a spot color.- Parameters:
sp
- the spot colortint
- the tint for the spot color. 0 is no color and 1 is 100% color
-
setPatternFill
Sets the fill color to a pattern. The pattern can be colored or uncolored.- Parameters:
p
- the pattern
-
outputColorNumbers
Outputs the color values to the content.- Parameters:
color
- The colortint
- the tint if it is a spot color, ignored otherwise
-
setPatternFill
Sets the fill color to an uncolored pattern.- Parameters:
p
- the patterncolor
- the color of the pattern
-
setPatternFill
Sets the fill color to an uncolored pattern.- Parameters:
p
- the patterncolor
- the color of the patterntint
- the tint if the color is a spot color, ignored otherwise
-
setPatternStroke
Sets the stroke color to an uncolored pattern.- Parameters:
p
- the patterncolor
- the color of the pattern
-
setPatternStroke
Sets the stroke color to an uncolored pattern.- Parameters:
p
- the patterncolor
- the color of the patterntint
- the tint if the color is a spot color, ignored otherwise
-
setPatternStroke
Sets the stroke color to a pattern. The pattern can be colored or uncolored.- Parameters:
p
- the pattern
-
paintShading
Paints using a shading object.- Parameters:
shading
- the shading object
-
paintShading
Paints using a shading pattern.- Parameters:
shading
- the shading pattern
-
setShadingFill
Sets the shading fill pattern.- Parameters:
shading
- the shading pattern
-
setShadingStroke
Sets the shading stroke pattern- Parameters:
shading
- the shading pattern
-
checkWriter
protected void checkWriter()Check if we have a valid PdfWriter. -
showText
Show an array of text.- Parameters:
text
- array of text
-
getPdfWriter
Gets thePdfWriter
in use by this object.- Returns:
- the
PdfWriter
in use by this object
-
getPdfDocument
Gets thePdfDocument
in use by this object.- Returns:
- the
PdfDocument
in use by this object
-
localGoto
Implements a link to other part of the document. The jump will be made to a local destination with the same name, that must exist.- Parameters:
name
- the name for this linkllx
- the lower left x corner of the activation areally
- the lower left y corner of the activation areaurx
- the upper right x corner of the activation areaury
- the upper right y corner of the activation area
-
localDestination
The local destination to where a local goto with the same name will jump.- Parameters:
name
- the name of this local destinationdestination
- thePdfDestination
with the jump coordinates- Returns:
true
if the local destination was added,false
if a local destination with the same name already exists
-
getDuplicate
Gets a duplicate of thisPdfContentByte
. All the members are copied by reference but the buffer stays different.- Returns:
- a copy of this
PdfContentByte
-
remoteGoto
Implements a link to another document.- Parameters:
filename
- the filename for the remote documentname
- the name to jump tollx
- the lower left x corner of the activation areally
- the lower left y corner of the activation areaurx
- the upper right x corner of the activation areaury
- the upper right y corner of the activation area
-
remoteGoto
Implements a link to another document.- Parameters:
filename
- the filename for the remote documentpage
- the page to jump tollx
- the lower left x corner of the activation areally
- the lower left y corner of the activation areaurx
- the upper right x corner of the activation areaury
- the upper right y corner of the activation area
-
roundRectangle
public void roundRectangle(float x, float y, float w, float h, float r) Adds a round rectangle to the current path.- Parameters:
x
- x-coordinate of the starting pointy
- y-coordinate of the starting pointw
- widthh
- heightr
- radius of the arc corner
-
setAction
Implements an action in an area.- Parameters:
action
- thePdfAction
llx
- the lower left x corner of the activation areally
- the lower left y corner of the activation areaurx
- the upper right x corner of the activation areaury
- the upper right y corner of the activation area
-
setLiteral
Outputs aString
directly to the content.- Parameters:
s
- theString
-
setLiteral
public void setLiteral(char c) Outputs achar
directly to the content.- Parameters:
c
- thechar
-
setLiteral
public void setLiteral(float n) Outputs afloat
directly to the content.- Parameters:
n
- thefloat
-
checkNoPattern
Throws an error if it is a pattern.- Parameters:
t
- the object to check
-
drawRadioField
public void drawRadioField(float llx, float lly, float urx, float ury, boolean on) Draws a TextField.- Parameters:
llx
- lower-left-xlly
- lower-left-yurx
- upper-right-xury
- upper-right-yon
- if radio is selected or not
-
drawTextField
public void drawTextField(float llx, float lly, float urx, float ury) Draws a TextField.- Parameters:
llx
- lower-left-xlly
- lower-left-yurx
- upper-right-xury
- upper-right-y
-
drawButton
public void drawButton(float llx, float lly, float urx, float ury, String text, BaseFont bf, float size) Draws a button.- Parameters:
llx
- lower-left-xlly
- lower-left-yurx
- upper-right-xury
- upper-right-ytext
- textbf
-BaseFont
size
- size
-
createGraphicsShapes
Gets aGraphics2D
to write on. The graphics are translated to PDF commands as shapes. No PDF fonts will appear.- Parameters:
width
- the width of the panelheight
- the height of the panel- Returns:
- a
Graphics2D
-
createPrinterGraphicsShapes
Gets aGraphics2D
to print on. The graphics are translated to PDF commands as shapes. No PDF fonts will appear.- Parameters:
width
- the width of the panelheight
- the height of the panelprinterJob
- a printer job- Returns:
- a
Graphics2D
-
createGraphics
Gets aGraphics2D
to write on. The graphics are translated to PDF commands.- Parameters:
width
- the width of the panelheight
- the height of the panel- Returns:
- a
Graphics2D
-
createPrinterGraphics
Gets aGraphics2D
to print on. The graphics are translated to PDF commands.- Parameters:
width
- width of the panelheight
- height of the panelprinterJob
-PrinterJob
- Returns:
- a
Graphics2D
-
createGraphics
public Graphics2D createGraphics(float width, float height, boolean convertImagesToJPEG, float quality) Gets aGraphics2D
to write on. The graphics are translated to PDF commands.- Parameters:
width
- width of the panelheight
- height of the panelconvertImagesToJPEG
- if convert images to JPEGquality
- quality fo the print- Returns:
- a
Graphics2D
-
createPrinterGraphics
public Graphics2D createPrinterGraphics(float width, float height, boolean convertImagesToJPEG, float quality, PrinterJob printerJob) Gets aGraphics2D
to print on. The graphics are translated to PDF commands.- Parameters:
width
- width of the panelheight
- height of the panelconvertImagesToJPEG
- if convert images to JPEGquality
- quality fo the printprinterJob
-PrinterJob
- Returns:
- a
Graphics2D
-
createGraphicsShapes
public Graphics2D createGraphicsShapes(float width, float height, boolean convertImagesToJPEG, float quality) Gets aGraphics2D
to print on. The graphics are translated to PDF commands.- Parameters:
width
- width of the panelheight
- height of the panelconvertImagesToJPEG
- if convert images to JPEGquality
- quality fo the print- Returns:
- A Graphics2D object
-
createPrinterGraphicsShapes
public Graphics2D createPrinterGraphicsShapes(float width, float height, boolean convertImagesToJPEG, float quality, PrinterJob printerJob) Gets aGraphics2D
to print on. The graphics are translated to PDF commands.- Parameters:
width
- width of the panelheight
- height of the panelconvertImagesToJPEG
- if convert images to JPEGquality
- quality fo the printprinterJob
-PrinterJob
- Returns:
- a Graphics2D object
-
createGraphics
Gets aGraphics2D
to write on. The graphics are translated to PDF commands.- Parameters:
width
- the width of the panelheight
- the height of the panelfontMapper
- the mapping from awt fonts toBaseFont
- Returns:
- a
Graphics2D
-
createPrinterGraphics
public Graphics2D createPrinterGraphics(float width, float height, FontMapper fontMapper, PrinterJob printerJob) Gets aGraphics2D
to print on. The graphics are translated to PDF commands.- Parameters:
width
- the width of the panelheight
- the height of the panelfontMapper
- the mapping from awt fonts toBaseFont
printerJob
- a printer job- Returns:
- a
Graphics2D
-
createGraphics
public Graphics2D createGraphics(float width, float height, FontMapper fontMapper, boolean convertImagesToJPEG, float quality) Gets aGraphics2D
to write on. The graphics are translated to PDF commands.- Parameters:
width
- the width of the panelheight
- the height of the panelfontMapper
- the mapping from awt fonts toBaseFont
convertImagesToJPEG
- converts awt images to jpeg before inserting in pdfquality
- the quality of the jpeg- Returns:
- a
Graphics2D
-
createPrinterGraphics
public Graphics2D createPrinterGraphics(float width, float height, FontMapper fontMapper, boolean convertImagesToJPEG, float quality, PrinterJob printerJob) Gets aGraphics2D
to print on. The graphics are translated to PDF commands.- Parameters:
width
- the width of the panelheight
- the height of the panelfontMapper
- the mapping from awt fonts toBaseFont
convertImagesToJPEG
- converts awt images to jpeg before inserting in pdfquality
- the quality of the jpegprinterJob
- a printer job- Returns:
- a
Graphics2D
-
getPageResources
PageResources getPageResources() -
setGState
Sets the graphic state- Parameters:
gstate
- the graphic state
-
beginLayer
Begins a graphic block whose visibility is controlled by thelayer
. Blocks can be nested. Each block must be terminated by anendLayer()
.Note that nested layers with
PdfLayer.addChild(PdfLayer)
only require a single call to this method and a single call toendLayer()
; all the nesting control is built in.- Parameters:
layer
- the layer
-
beginLayer2
-
endLayer
public void endLayer()Ends a layer controlled graphic block. It will end the most recent open block. -
transform
Concatenates a transformation to the current transformation matrix.- Parameters:
af
- the transformation
-
addAnnotation
-
setDefaultColorspace
Sets the default colorspace.- Parameters:
name
- the name of the colorspace. It can bePdfName.DEFAULTGRAY
,PdfName.DEFAULTRGB
orPdfName.DEFAULTCMYK
obj
- the colorspace. Anull
orPdfNull
removes any colorspace with the same name
-
beginMarkedContentSequence
Begins a marked content sequence. This sequence will be tagged with the structurestruc
. The same structure can be used several times to connect text that belongs to the same logical segment but is in a different location, like the same paragraph crossing to another page, for example.- Parameters:
struc
- the tagging structure
-
beginMarkedContentSequence
-
endMarkedContentSequence
public void endMarkedContentSequence()Ends a marked content sequence -
beginMarkedContentSequence
Begins a marked content sequence. If property isnull
the mark will be of the typeBMC
otherwise it will beBDC
.- Parameters:
tag
- the tagproperty
- the propertyinline
-true
to include the property in the content orfalse
to include the property in the resource dictionary with the possibility of reusing
-
beginMarkedContentSequence
This is just a shorthand tobeginMarkedContentSequence(tag, null, false)
.- Parameters:
tag
- the tag
-
sanityCheck
public void sanityCheck()Checks for any dangling state: Mismatched save/restore state, begin/end text, begin/end layer, or begin/end marked content sequence. If found, this function will throw. This function is called automatically during a reset() (from Document.newPage() for example), and before writing itself out in toPdf(). One possible cause: not calling myPdfGraphics2D.dispose() will leave dangling saveState() calls.- Throws:
IllegalPdfSyntaxException
- (a runtime exception)- Since:
- 2.1.6
-