|
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.lowagie.text.pdf.PdfContentByte
public class PdfContentByte
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 | |
|---|---|
(package private) static class |
PdfContentByte.GraphicState
This class keeps the graphic state of the current page |
| Field Summary | |
|---|---|
private static HashMap |
abrev
|
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 ArrayList |
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 PdfContentByte.GraphicState |
state
This is the GraphicState in use |
protected ArrayList |
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 |
private static float[] |
unitRect
|
protected PdfWriter |
writer
This is the writer |
| Constructor Summary | |
|---|---|
PdfContentByte(PdfWriter wr)
Constructs a new PdfContentByte-object. |
|
| Method Summary | |
|---|---|
void |
add(PdfContentByte other)
Adds the content of another PdfContent-object to this object. |
(package private) void |
addAnnotation(PdfAnnotation annot)
|
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. |
(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 the layer. |
private void |
beginLayer2(PdfOCG 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 |
beginText()
Starts the writing of text. |
static ArrayList |
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 |
checkNoPattern(PdfTemplate t)
Throws an error if it is a pattern. |
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. |
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. |
PdfAppearance |
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)
|
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. |
(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 |
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. |
(package private) static byte[] |
escapeString(byte[] b)
Escapes a byte array according to the PDF conventions. |
(package private) static void |
escapeString(byte[] b,
ByteBuffer content)
Escapes a byte 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 |
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. |
(package private) PageResources |
getPageResources()
|
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. |
private void |
HelperCMYK(float cyan,
float magenta,
float yellow,
float 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 components |
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. |
(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 |
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 |
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 |
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 |
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 |
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 |
setGrayStroke(float gray)
Changes the currentgray tint for stroking paths (device dependent colors!). |
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 |
setRGBColorFillF(float red,
float green,
float blue)
Changes the current color for filling paths (device dependent colors!). |
void |
setRGBColorStroke(int red,
int green,
int blue)
Changes the current color for stroking paths (device dependent colors!). |
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(PdfTextArray text)
Show an array of text. |
void |
showText(String text)
Shows the text. |
private void |
showText2(String text)
A helper to insert into the content stream the text
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 |
showTextKerned(String text)
Shows the text kerned. |
(package private) int |
size()
Gets the size of this content. |
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. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
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
private static final float[] unitRect
protected ByteBuffer content
protected PdfWriter writer
protected PdfDocument pdf
protected PdfContentByte.GraphicState state
protected ArrayList stateList
protected ArrayList layerDepth
protected int separator
private static HashMap abrev
| Constructor Detail |
|---|
public PdfContentByte(PdfWriter wr)
PdfContentByte-object.
wr - the writer associated to this content| Method Detail |
|---|
public String toString()
String representation of this PdfContentByte-object.
toString in class ObjectStringpublic 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 phase
public 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()