public class PdfContentByte extends Object
PdfContentByte
is an object containing the user positioned
text and graphic contents of a page. It knows how to apply the proper
font encoding.Modifier and Type | Field and Description |
---|---|
static int |
ALIGN_CENTER
The alignment is center
|
static int |
ALIGN_LEFT
The alignment is left
|
static int |
ALIGN_RIGHT
The alignment is right
|
protected ByteBuffer |
content
This is the actual content
|
protected List<Integer> |
layerDepth
The list were we save/restore the layer depth
|
static int |
LINE_CAP_BUTT
A possible line cap value
|
static int |
LINE_CAP_PROJECTING_SQUARE
A possible line cap value
|
static int |
LINE_CAP_ROUND
A possible line cap value
|
static int |
LINE_JOIN_BEVEL
A possible line join value
|
static int |
LINE_JOIN_MITER
A possible line join value
|
static int |
LINE_JOIN_ROUND
A possible line join value
|
protected PdfDocument |
pdf
This is the PdfDocument
|
protected int |
separator
The separator between commands.
|
protected com.lowagie.text.pdf.PdfContentByte.GraphicState |
state
This is the GraphicState in use
|
protected List<com.lowagie.text.pdf.PdfContentByte.GraphicState> |
stateList
The list were we save/restore the state
|
static int |
TEXT_RENDER_MODE_CLIP
A possible text rendering value
|
static int |
TEXT_RENDER_MODE_FILL
A possible text rendering value
|
static int |
TEXT_RENDER_MODE_FILL_CLIP
A possible text rendering value
|
static int |
TEXT_RENDER_MODE_FILL_STROKE
A possible text rendering value
|
static int |
TEXT_RENDER_MODE_FILL_STROKE_CLIP
A possible text rendering value
|
static int |
TEXT_RENDER_MODE_INVISIBLE
A possible text rendering value
|
static int |
TEXT_RENDER_MODE_STROKE
A possible text rendering value
|
static int |
TEXT_RENDER_MODE_STROKE_CLIP
A possible text rendering value
|
protected PdfWriter |
writer
This is the writer
|
Constructor and Description |
---|
PdfContentByte(PdfWriter wr)
Constructs a new
PdfContentByte -object. |
Modifier and Type | Method and Description |
---|---|
void |
add(PdfContentByte other)
Adds the content of another
PdfContent -object to this object. |
void |
addImage(Image image)
Adds an
Image to the page. |
void |
addImage(Image image,
boolean inlineImage)
Adds an
Image to the page. |
void |
addImage(Image image,
float a,
float b,
float c,
float d,
float e,
float f)
Adds an
Image to the page. |
void |
addImage(Image image,
float a,
float b,
float c,
float d,
float e,
float f,
boolean inlineImage)
Adds an
Image 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,
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.
|
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 the
layer . |
void |
beginMarkedContentSequence(PdfName tag)
This is just a shorthand to
beginMarkedContentSequence(tag, null, false) . |
void |
beginMarkedContentSequence(PdfName tag,
PdfDictionary property,
boolean inline)
Begins a marked content sequence.
|
void |
beginMarkedContentSequence(PdfStructureElement struc)
Begins a marked content sequence.
|
void |
beginMarkedContentSequence(PdfStructureElement struc,
PdfDictionary dict) |
void |
beginText()
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.
|
protected void |
checkWriter()
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 |
closePath()
Closes the current subpath by appending a straight line segment from the current point
to the starting point of the subpath.
|
void |
closePathEoFillStroke()
Closes the path, fills it using the even-odd rule to determine the region to fill and strokes it.
|
void |
closePathFillStroke()
Closes the path, fills it using the non-zero winding number rule to determine the region to fill and strokes it.
|
void |
closePathStroke()
Closes the path and strokes it.
|
void |
concatCTM(float a,
float b,
float c,
float d,
float e,
float f)
Concatenate a matrix to the current transformation matrix.
|
PdfAppearance |
createAppearance(float width,
float height)
Creates a new appearance to be used with form fields.
|
Graphics2D |
createGraphics(float width,
float height)
Gets a
Graphics2D to write on. |
Graphics2D |
createGraphics(float width,
float height,
boolean convertImagesToJPEG,
float quality)
Gets a
Graphics2D to write on. |
Graphics2D |
createGraphics(float width,
float height,
FontMapper fontMapper)
Gets a
Graphics2D to write on. |
Graphics2D |
createGraphics(float width,
float height,
FontMapper fontMapper,
boolean convertImagesToJPEG,
float quality)
Gets a
Graphics2D to write on. |
Graphics2D |
createGraphicsShapes(float width,
float height)
Gets a
Graphics2D to write on. |
Graphics2D |
createGraphicsShapes(float width,
float height,
boolean convertImagesToJPEG,
float quality)
Gets a
Graphics2D to print on. |
PdfPatternPainter |
createPattern(float width,
float height)
Create a new colored tiling pattern.
|
PdfPatternPainter |
createPattern(float width,
float height,
Color color)
Create a new uncolored tiling pattern.
|
PdfPatternPainter |
createPattern(float width,
float height,
float xstep,
float ystep)
Create a new colored tiling pattern.
|
PdfPatternPainter |
createPattern(float width,
float height,
float xstep,
float ystep,
Color color)
Create a new uncolored tiling pattern.
|
Graphics2D |
createPrinterGraphics(float width,
float height,
boolean convertImagesToJPEG,
float quality,
PrinterJob printerJob)
Gets a
Graphics2D to print on. |
Graphics2D |
createPrinterGraphics(float width,
float height,
FontMapper fontMapper,
boolean convertImagesToJPEG,
float quality,
PrinterJob printerJob)
Gets a
Graphics2D to print on. |
Graphics2D |
createPrinterGraphics(float width,
float height,
FontMapper fontMapper,
PrinterJob printerJob)
Gets a
Graphics2D to print on. |
Graphics2D |
createPrinterGraphics(float width,
float height,
PrinterJob printerJob)
Gets a
Graphics2D to print on. |
Graphics2D |
createPrinterGraphicsShapes(float width,
float height,
boolean convertImagesToJPEG,
float quality,
PrinterJob printerJob)
Gets a
Graphics2D to print on. |
Graphics2D |
createPrinterGraphicsShapes(float width,
float height,
PrinterJob printerJob)
Gets a
Graphics2D to print on. |
PdfTemplate |
createTemplate(float width,
float height)
Creates a new template.
|
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 |
endMarkedContentSequence()
Ends a marked content sequence
|
void |
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 |
eoFillStroke()
Fills the path, using the even-odd rule to determine the region to fill and strokes it.
|
void |
fill()
Fills the path, using the non-zero winding number rule to determine the region to fill.
|
void |
fillStroke()
Fills the path using the non-zero winding number rule to determine the region to fill and strokes it.
|
float |
getCharacterSpacing()
Gets the current character spacing.
|
PdfContentByte |
getDuplicate()
Gets a duplicate of this
PdfContentByte . |
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 |
getHorizontalScaling()
Gets the current character spacing.
|
ByteBuffer |
getInternalBuffer()
Gets the internal buffer.
|
static PdfTextArray |
getKernArray(String text,
BaseFont font)
Constructs a kern array for a text in a certain font
|
float |
getLeading()
Gets the current text leading.
|
PdfDocument |
getPdfDocument()
Gets the
PdfDocument in use by this object. |
PdfWriter |
getPdfWriter()
Gets the
PdfWriter in use by this object. |
PdfOutline |
getRootOutline()
Gets the root outline.
|
float |
getWordSpacing()
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.
|
void |
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 |
localGoto(String name,
float llx,
float lly,
float urx,
float ury)
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.
|
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 shows
text . |
void |
newlineText()
Moves to the start of the next line.
|
void |
newPath()
Ends the path without filling or stroking it.
|
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 |
rectangle(Rectangle rectangle)
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 this
PdfContentByte empty. |
void |
reset(boolean validateContent)
Makes this
PdfContentByte empty. |
void |
resetCMYKColorFill()
Changes the current color for filling paths to black.
|
void |
resetCMYKColorStroke()
Changes the current color for stroking paths to black.
|
void |
resetGrayFill()
Changes the current gray tint for filling paths to black.
|
void |
resetGrayStroke()
Changes the current gray tint for stroking paths to black.
|
void |
resetRGBColorFill()
Changes the current color for filling paths to black.
|
void |
resetRGBColorStroke()
Changes the current color for stroking paths to black.
|
void |
restoreState()
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 |
sanityCheck()
Checks for any dangling state: Mismatched save/restore state, begin/end text,
begin/end layer, or begin/end marked content sequence.
|
void |
saveState()
Saves the graphic state.
|
void |
setAction(PdfAction action,
float llx,
float lly,
float urx,
float ury)
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(Color color)
Sets the fill color.
|
void |
setColorFill(PdfSpotColor sp,
float tint)
Sets the fill color to a spot color.
|
void |
setColorStroke(Color color)
Sets the stroke color.
|
void |
setColorStroke(PdfSpotColor sp,
float tint)
Sets the stroke color to a spot 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 |
setGState(PdfGState gstate)
Sets the graphic state
|
void |
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.
|
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 a
char directly to the content. |
void |
setLiteral(float n)
Outputs a
float directly to the content. |
void |
setLiteral(String s)
Outputs a
String directly to the content. |
void |
setMiterLimit(float miterLimit)
Changes the Miter limit.
|
void |
setPatternFill(PdfPatternPainter p)
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 |
setPatternStroke(PdfPatternPainter p)
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 pattern
|
void |
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(GlyphVector glyphVector) |
void |
showText(PdfTextArray text)
Show an array of text.
|
void |
showText(String text)
Shows the
text . |
void |
showTextAligned(int alignment,
String text,
float x,
float y,
float rotation)
Shows text right, left or center aligned with rotation.
|
void |
showTextAlignedKerned(int alignment,
String text,
float x,
float y,
float rotation)
Shows text kerned right, left or center aligned with rotation.
|
void |
showTextKerned(String text)
Shows the
text kerned. |
void |
stroke()
Strokes the path.
|
byte[] |
toPdf(PdfWriter writer)
Returns the PDF representation of this
PdfContentByte -object. |
String |
toString()
Returns the
String representation of this PdfContentByte -object. |
void |
transform(AffineTransform af)
Concatenates a transformation to the current transformation
matrix.
|
void |
variableRectangle(Rectangle rect)
Adds a variable width border to the current path.
|
public static final int ALIGN_CENTER
public static final int ALIGN_LEFT
public static final int ALIGN_RIGHT
public static final int LINE_CAP_BUTT
public static final int LINE_CAP_ROUND
public static final int LINE_CAP_PROJECTING_SQUARE
public static final int LINE_JOIN_MITER
public static final int LINE_JOIN_ROUND
public static final int LINE_JOIN_BEVEL
public static final int TEXT_RENDER_MODE_FILL
public static final int TEXT_RENDER_MODE_STROKE
public static final int TEXT_RENDER_MODE_FILL_STROKE
public static final int TEXT_RENDER_MODE_INVISIBLE
public static final int TEXT_RENDER_MODE_FILL_CLIP
public static final int TEXT_RENDER_MODE_STROKE_CLIP
public static final int TEXT_RENDER_MODE_FILL_STROKE_CLIP
public static final int TEXT_RENDER_MODE_CLIP
protected ByteBuffer content
protected PdfWriter writer
protected PdfDocument pdf
protected com.lowagie.text.pdf.PdfContentByte.GraphicState state
protected List<com.lowagie.text.pdf.PdfContentByte.GraphicState> stateList
protected int separator
public PdfContentByte(PdfWriter wr)
PdfContentByte
-object.wr
- the writer associated to this contentpublic String toString()
String
representation of this PdfContentByte
-object.public ByteBuffer getInternalBuffer()
public byte[] toPdf(PdfWriter writer)
PdfContentByte
-object.writer
- the PdfWriter
byte
array with the representationpublic void add(PdfContentByte other)
PdfContent
-object to this object.other
- another PdfByteContent
-objectpublic float getXTLM()
public float getYTLM()
public float getLeading()
public float getCharacterSpacing()
public float getWordSpacing()
public float getHorizontalScaling()
public void setFlatness(float flatness)
Flatness sets the maximum permitted distance in device pixels between the
mathematically correct path and an approximation constructed from straight line segments.
flatness
- a valuepublic void setLineCap(int 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.
style
- a valuepublic void setLineDash(float phase)
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.
phase
- the value of the phasepublic void setLineDash(float unitsOn, float phase)
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.
phase
- the value of the phaseunitsOn
- the number of units that must be 'on' (equals the number of units that must be 'off').public void setLineDash(float unitsOn, float unitsOff, float phase)
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.
phase
- the value of the phaseunitsOn
- the number of units that must be 'on'unitsOff
- the number of units that must be 'off'public final void setLineDash(float[] array, float phase)
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.
array
- length of the alternating dashes and gapsphase
- the value of the phasepublic void setLineJoin(int 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).
style
- a valuepublic void setLineWidth(float w)
The line width specifies the thickness of the line used to stroke a path and is measured
in user space units.
w
- a widthpublic void setMiterLimit(float miterLimit)
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.
miterLimit
- a miter limitpublic void clip()
public void eoClip()
public void setGrayFill(float gray)
Sets the color space to DeviceGray (or the DefaultGray color space), and sets the gray tint to use for filling paths.
gray
- a value between 0 (black) and 1 (white)public void setGrayFill(float gray, float alpha)
public void resetGrayFill()
public void setGrayStroke(float gray)
Sets the color space to DeviceGray (or the DefaultGray color space), and sets the gray tint to use for stroking paths.
gray
- a value between 0 (black) and 1 (white)public void setGrayStroke(float gray, float alpha)
public void resetGrayStroke()
public void setRGBColorFillF(float red, float green, float blue)
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).
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 1public void setRGBColorFillF(float red, float green, float blue, float alpha)
public void resetRGBColorFill()
public void setRGBColorStrokeF(float red, float green, float blue)
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).
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 1public void resetRGBColorStroke()
public void setCMYKColorFillF(float cyan, float magenta, float yellow, float black)
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).
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 1public void setCMYKColorFillF(float cyan, float magenta, float yellow, float black, float alpha)
public void resetCMYKColorFill()
public void setCMYKColorStrokeF(float cyan, float magenta, float yellow, float black)
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).
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 1public void setCMYKColorStrokeF(float cyan, float magenta, float yellow, float black, float alpha)
public void resetCMYKColorStroke()
public void moveTo(float x, float y)
x
- new x-coordinatey
- new y-coordinatepublic void lineTo(float x, float y)
x
- new x-coordinatey
- new y-coordinatepublic void curveTo(float x1, float y1, float x2, float y2, float x3, float y3)
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)public void curveTo(float x2, float y2, float x3, float y3)
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)public void curveFromTo(float x1, float y1, float x3, float y3)
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)public void circle(float x, float y, float r)
x
- x center of circley
- y center of circler
- radius of circlepublic void rectangle(float x, float y, float w, float h)
x
- x-coordinate of the starting pointy
- y-coordinate of the starting pointw
- widthh
- heightpublic void variableRectangle(Rectangle rect)
Rectangle.isUseVariableBorders
= true.rect
- a Rectangle
public void rectangle(Rectangle rectangle)
rectangle
- a Rectangle
public void closePath()
public void newPath()
public void stroke()
public void closePathStroke()
public void fill()
public void eoFill()
public void fillStroke()
public void closePathFillStroke()
public void eoFillStroke()
public void closePathEoFillStroke()
public void addImage(Image image) throws DocumentException
Image
to the page. The Image
must have
absolute positioning.image
- the Image
objectDocumentException
- if the Image
does not have absolute positioningpublic void addImage(Image image, boolean inlineImage) throws DocumentException
Image
to the page. The Image
must have
absolute positioning. The image can be placed inline.image
- the Image
objectinlineImage
- true
to place this image inline, false
otherwiseDocumentException
- if the Image
does not have absolute positioningpublic void addImage(Image image, float a, float b, float c, float d, float e, float f) throws DocumentException
Image
to the page. The positioning of the Image
is done with the transformation matrix. To position an image
at (x,y)
use addImage(image, image_width, 0, 0, image_height, x, y).image
- the Image
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 matrixDocumentException
- on errorpublic void addImage(Image image, float a, float b, float c, float d, float e, float f, boolean inlineImage) throws DocumentException
Image
to the page. The positioning of the Image
is done with the transformation matrix. To position an image
at (x,y)
use addImage(image, image_width, 0, 0, image_height, x, y). The image can be placed inline.image
- the Image
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
otherwiseDocumentException
- on errorpublic void reset()
PdfContentByte
empty.
Calls reset( true )
public void reset(boolean validateContent)
PdfContentByte
empty.validateContent
- will call sanityCheck()
if true.public void beginText()
public void endText()
public void saveState()
saveState
and
restoreState
must be balanced.public void restoreState()
saveState
and
restoreState
must be balanced.public void setCharacterSpacing(float charSpace)
charSpace
- a parameterpublic void setWordSpacing(float wordSpace)
wordSpace
- a parameterpublic void setHorizontalScaling(float scale)
scale
- a parameterpublic void setLeading(float leading)
The leading parameter is measured in text space units. It specifies the vertical distance between the baselines of adjacent lines of text.
leading
- the new leadingpublic void setFontAndSize(BaseFont bf, float size)
bf
- the fontsize
- the font size in pointspublic void setTextRenderingMode(int rendering)
rendering
- a parameterpublic void setTextRise(float rise)
This allows to write text in subscript or superscript mode.
rise
- a parameterpublic void showText(String text)
text
.text
- the text to writepublic void showText(GlyphVector glyphVector)
public static PdfTextArray getKernArray(String text, BaseFont font)
text
- the textfont
- the fontpublic void showTextKerned(String text)
text
kerned.text
- the text to writepublic void newlineShowText(String text)
text
.text
- the text to writepublic void newlineShowText(float wordSpacing, float charSpacing, String text)
wordSpacing
- a parametercharSpacing
- a parametertext
- the text to writepublic void setTextMatrix(float a, float b, float c, float d, float x, float y)
Remark: this operation also initializes the current point position.
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 matrixpublic void setTextMatrix(float x, float y)
Remark: this operation also initializes the current point position.
x
- operand 3,1 in the matrixy
- operand 3,2 in the matrixpublic void moveText(float x, float y)
x
- x-coordinate of the new current pointy
- y-coordinate of the new current pointpublic void moveTextWithLeading(float x, float y)
As a side effect, this sets the leading parameter in the text state.
x
- offset of the new current pointy
- y-coordinate of the new current pointpublic void newlineText()
public void addOutline(PdfOutline outline, String name)
outline
- the outlinename
- the name for the local destinationpublic PdfOutline getRootOutline()
public float getEffectiveStringWidth(String text, boolean kerned)
text
- the string to get width ofkerned
- the kerning optionpublic void showTextAligned(int alignment, String text, float x, float y, float rotation)
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 counterclockwisepublic void showTextAlignedKerned(int alignment, String text, float x, float y, float rotation)
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 counterclockwisepublic void concatCTM(float a, float b, float c, float d, float e, float f)
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 matrixpublic static List<float[]> bezierArc(float x1, float y1, float x2, float y2, float startAng, float extent)
(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 ).
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 degreespublic void arc(float x1, float y1, float x2, float y2, float startAng, float extent)
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 degreespublic void ellipse(float x1, float y1, float x2, float y2)
x1
- a corner of the enclosing rectangley1
- a corner of the enclosing rectanglex2
- a corner of the enclosing rectangley2
- a corner of the enclosing rectanglepublic PdfPatternPainter createPattern(float width, float height, float xstep, float ystep)
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.PdfPatternPainter
where the pattern will be createdpublic PdfPatternPainter createPattern(float width, float height)
width
- the width of the patternheight
- the height of the patternPdfPatternPainter
where the pattern will be createdpublic PdfPatternPainter createPattern(float width, float height, float xstep, float ystep, Color color)
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 be null
PdfPatternPainter
where the pattern will be createdpublic PdfPatternPainter createPattern(float width, float height, Color color)
width
- the width of the patternheight
- the height of the patterncolor
- the default color. Can be null
PdfPatternPainter
where the pattern will be createdpublic PdfTemplate createTemplate(float width, float height)
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.
width
- the bounding box widthheight
- the bounding box heightpublic PdfAppearance createAppearance(float width, float height)
width
- the bounding box widthheight
- the bounding box heightpublic void addPSXObject(PdfPSXObject psobject)
psobject
- the objectpublic void addTemplate(PdfTemplate template, float a, float b, float c, float d, float e, float f)
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 matrixpublic void addTemplate(PdfTemplate template, float x, float y)
template
- the templatex
- the x location of this templatey
- the y location of this templatepublic void setCMYKColorFill(int cyan, int magenta, int yellow, int black)
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.
cyan
- the intensity of cyanmagenta
- the intensity of magentayellow
- the intensity of yellowblack
- the intensity of blackpublic void setCMYKColorStroke(int cyan, int magenta, int yellow, int black)
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.cyan
- the intensity of redmagenta
- the intensity of greenyellow
- the intensity of blueblack
- the intensity of blackpublic void setRGBColorFill(int red, int green, int blue)
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.
red
- the intensity of redgreen
- the intensity of greenblue
- the intensity of bluepublic void setRGBColorFill(int red, int green, int blue, int alpha)
public void setRGBColorStroke(int red, int green, int blue)
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.red
- the intensity of redgreen
- the intensity of greenblue
- the intensity of bluepublic void setRGBColorStroke(int red, int green, int blue, int alpha)
public void setColorStroke(Color color)
color
can be an
ExtendedColor
.color
- the colorpublic void setColorFill(Color color)
color
can be an
ExtendedColor
.color
- the colorpublic void setColorFill(PdfSpotColor sp, float tint)
sp
- the spot colortint
- the tint for the spot color. 0 is no color and 1
is 100% colorpublic void setColorStroke(PdfSpotColor sp, float tint)
sp
- the spot colortint
- the tint for the spot color. 0 is no color and 1
is 100% colorpublic void setPatternFill(PdfPatternPainter p)
p
- the patternpublic void setPatternFill(PdfPatternPainter p, Color color)
p
- the patterncolor
- the color of the patternpublic void setPatternFill(PdfPatternPainter p, Color color, float tint)
p
- the patterncolor
- the color of the patterntint
- the tint if the color is a spot color, ignored otherwisepublic void setPatternStroke(PdfPatternPainter p, Color color)
p
- the patterncolor
- the color of the patternpublic void setPatternStroke(PdfPatternPainter p, Color color, float tint)
p
- the patterncolor
- the color of the patterntint
- the tint if the color is a spot color, ignored otherwisepublic void setPatternStroke(PdfPatternPainter p)
p
- the patternpublic void paintShading(PdfShading shading)
shading
- the shading objectpublic void paintShading(PdfShadingPattern shading)
shading
- the shading patternpublic void setShadingFill(PdfShadingPattern shading)
shading
- the shading patternpublic void setShadingStroke(PdfShadingPattern shading)
shading
- the shading patternprotected void checkWriter()
public void showText(PdfTextArray text)
text
- array of textpublic PdfWriter getPdfWriter()
PdfWriter
in use by this object.PdfWriter
in use by this objectpublic PdfDocument getPdfDocument()
PdfDocument
in use by this object.PdfDocument
in use by this objectpublic void localGoto(String name, float llx, float lly, float urx, float ury)
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 areapublic boolean localDestination(String name, PdfDestination destination)
name
- the name of this local destinationdestination
- the PdfDestination
with the jump coordinatestrue
if the local destination was added,
false
if a local destination with the same name
already existspublic PdfContentByte getDuplicate()
PdfContentByte
. All
the members are copied by reference but the buffer stays different.PdfContentByte
public void remoteGoto(String filename, String name, float llx, float lly, float urx, float ury)
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 areapublic void remoteGoto(String filename, int page, float llx, float lly, float urx, float ury)
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 areapublic void roundRectangle(float x, float y, float w, float h, float r)
x
- x-coordinate of the starting pointy
- y-coordinate of the starting pointw
- widthh
- heightr
- radius of the arc cornerpublic void setAction(PdfAction action, float llx, float lly, float urx, float ury)
action
- the PdfAction
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 areapublic void setLiteral(String s)
String
directly to the content.s
- the String
public void setLiteral(char c)
char
directly to the content.c
- the char
public void setLiteral(float n)
float
directly to the content.n
- the float
public void drawRadioField(float llx, float lly, float urx, float ury, boolean on)
llx
- lower-left-xlly
- lower-left-yurx
- upper-right-xury
- upper-right-yon
- if radio is selected or notpublic void drawTextField(float llx, float lly, float urx, float ury)
llx
- lower-left-xlly
- lower-left-yurx
- upper-right-xury
- upper-right-ypublic void drawButton(float llx, float lly, float urx, float ury, String text, BaseFont bf, float size)
llx
- lower-left-xlly
- lower-left-yurx
- upper-right-xury
- upper-right-ytext
- textbf
- BaseFont
size
- sizepublic Graphics2D createGraphicsShapes(float width, float height)
Graphics2D
to write on. The graphics
are translated to PDF commands as shapes. No PDF fonts will appear.width
- the width of the panelheight
- the height of the panelGraphics2D
public Graphics2D createPrinterGraphicsShapes(float width, float height, PrinterJob printerJob)
Graphics2D
to print on. The graphics
are translated to PDF commands as shapes. No PDF fonts will appear.width
- the width of the panelheight
- the height of the panelprinterJob
- a printer jobGraphics2D
public Graphics2D createGraphics(float width, float height)
Graphics2D
to write on. The graphics
are translated to PDF commands.width
- the width of the panelheight
- the height of the panelGraphics2D
public Graphics2D createPrinterGraphics(float width, float height, PrinterJob printerJob)
Graphics2D
to print on. The graphics
are translated to PDF commands.width
- width of the panelheight
- height of the panelprinterJob
- PrinterJob
Graphics2D
public Graphics2D createGraphics(float width, float height, boolean convertImagesToJPEG, float quality)
Graphics2D
to write on. The graphics
are translated to PDF commands.width
- width of the panelheight
- height of the panelconvertImagesToJPEG
- if convert images to JPEGquality
- quality fo the printGraphics2D
public Graphics2D createPrinterGraphics(float width, float height, boolean convertImagesToJPEG, float quality, PrinterJob printerJob)
Graphics2D
to print on. The graphics
are translated to PDF commands.width
- width of the panelheight
- height of the panelconvertImagesToJPEG
- if convert images to JPEGquality
- quality fo the printprinterJob
- PrinterJob
Graphics2D
public Graphics2D createGraphicsShapes(float width, float height, boolean convertImagesToJPEG, float quality)
Graphics2D
to print on. The graphics
are translated to PDF commands.width
- width of the panelheight
- height of the panelconvertImagesToJPEG
- if convert images to JPEGquality
- quality fo the printpublic Graphics2D createPrinterGraphicsShapes(float width, float height, boolean convertImagesToJPEG, float quality, PrinterJob printerJob)
Graphics2D
to print on. The graphics
are translated to PDF commands.width
- width of the panelheight
- height of the panelconvertImagesToJPEG
- if convert images to JPEGquality
- quality fo the printprinterJob
- PrinterJob
public Graphics2D createGraphics(float width, float height, FontMapper fontMapper)
Graphics2D
to write on. The graphics
are translated to PDF commands.width
- the width of the panelheight
- the height of the panelfontMapper
- the mapping from awt fonts to BaseFont
Graphics2D
public Graphics2D createPrinterGraphics(float width, float height, FontMapper fontMapper, PrinterJob printerJob)
Graphics2D
to print on. The graphics
are translated to PDF commands.width
- the width of the panelheight
- the height of the panelfontMapper
- the mapping from awt fonts to BaseFont
printerJob
- a printer jobGraphics2D
public Graphics2D createGraphics(float width, float height, FontMapper fontMapper, boolean convertImagesToJPEG, float quality)
Graphics2D
to write on. The graphics
are translated to PDF commands.width
- the width of the panelheight
- the height of the panelfontMapper
- the mapping from awt fonts to BaseFont
convertImagesToJPEG
- converts awt images to jpeg before inserting in pdfquality
- the quality of the jpegGraphics2D
public Graphics2D createPrinterGraphics(float width, float height, FontMapper fontMapper, boolean convertImagesToJPEG, float quality, PrinterJob printerJob)
Graphics2D
to print on. The graphics
are translated to PDF commands.width
- the width of the panelheight
- the height of the panelfontMapper
- the mapping from awt fonts to BaseFont
convertImagesToJPEG
- converts awt images to jpeg before inserting in pdfquality
- the quality of the jpegprinterJob
- a printer jobGraphics2D
public void setGState(PdfGState gstate)
gstate
- the graphic statepublic void beginLayer(PdfOCG layer)
layer
.
Blocks can be nested. Each block must be terminated by an endLayer()
.
Note that nested layers with PdfLayer.addChild(PdfLayer)
only require a single
call to this method and a single call to endLayer()
; all the nesting control
is built in.
layer
- the layerpublic void endLayer()
public void transform(AffineTransform af)
af
- the transformationpublic void setDefaultColorspace(PdfName name, PdfObject obj)
name
- the name of the colorspace. It can be PdfName.DEFAULTGRAY
, PdfName.DEFAULTRGB
or PdfName.DEFAULTCMYK
obj
- the colorspace. A null
or PdfNull
removes any colorspace with the same namepublic void beginMarkedContentSequence(PdfStructureElement struc)
struc
.
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.struc
- the tagging structurepublic void beginMarkedContentSequence(PdfStructureElement struc, PdfDictionary dict)
public void endMarkedContentSequence()
public void beginMarkedContentSequence(PdfName tag, PdfDictionary property, boolean inline)
null
the mark will be of the type
BMC
otherwise it will be BDC
.tag
- the tagproperty
- the propertyinline
- true
to include the property in the content or false
to include the property in the resource dictionary with the possibility of reusingpublic void beginMarkedContentSequence(PdfName tag)
beginMarkedContentSequence(tag, null, false)
.tag
- the tagpublic void sanityCheck()
IllegalPdfSyntaxException
- (a runtime exception)Copyright © 2020. All rights reserved.