public class PDFContentGenerator
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected PDFPaintingState |
currentState
drawing state
|
protected PDFTextUtil |
textutil
Text generation utility holding the current font status
|
protected static boolean |
WRITE_COMMENTS
Controls whether comments are written to the PDF stream.
|
Constructor and Description |
---|
PDFContentGenerator(PDFDocument document,
java.io.OutputStream out,
PDFResourceContext resourceContext)
Main constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
add(java.lang.String content)
Adds content to the stream.
|
protected void |
beginMarkedContentSequence(java.lang.String structElemType,
int mcid)
Begins a new marked content sequence (BDC or BMC).
|
protected void |
beginTextObject()
Indicates the beginning of a text object.
|
protected void |
beginTextObject(java.lang.String structElemType,
int mcid)
Indicates the beginning of a marked-content text object.
|
void |
clipRect(java.awt.Rectangle rect)
Intersects the current clip region with the given rectangle.
|
protected void |
comment(java.lang.String text)
Writes out a comment.
|
void |
concatenate(java.awt.geom.AffineTransform transform)
Concatenates the given transformation matrix with the current one.
|
protected void |
endTextObject()
Indicates the end of a text object.
|
void |
flushPDFDoc()
Flushes all queued PDF objects ready to be written to the output stream.
|
static java.lang.String |
format(float value)
Formats a float value (normally coordinates in points) as Strings.
|
PDFDocument |
getDocument()
Returns the applicable resource context for the generator.
|
java.io.OutputStream |
getOutputStream()
Returns the output stream the PDF document is written to.
|
PDFResourceContext |
getResourceContext()
Returns the applicable resource context for the generator.
|
PDFPaintingState |
getState()
Returns the
PDFState associated with this instance. |
PDFStream |
getStream()
Returns the
PDFStream associated with this instance. |
PDFTextUtil |
getTextUtil()
Returns the
PDFTextUtil associated with this instance. |
void |
placeImage(float x,
float y,
float w,
float h,
PDFXObject xobj)
Places a previously registered image at a certain place on the page.
|
void |
placeImage(float x,
float y,
float w,
float h,
PDFXObject xobj,
java.lang.String structElemType,
int mcid)
Places a previously registered image at a certain place on the page,
bracketing it as a marked-content sequence.
|
protected void |
restoreGraphicsState()
Same as
restoreGraphicsState(boolean) , with true as
a parameter. |
protected void |
restoreGraphicsState(boolean popState)
Restored the graphics state valid before the previous
saveGraphicsState() . |
protected void |
restoreGraphicsStateAccess()
Same as
restoreGraphicsState() , additionally ending the current
marked content sequence if any. |
protected void |
saveGraphicsState() |
protected void |
saveGraphicsState(java.lang.String structElemType,
int sequenceNum) |
protected void |
separateTextElements(java.lang.String structElemType,
int mcid)
Separates 2 text elements, ending the current marked content sequence and
starting a new one.
|
void |
setColor(java.awt.Color col,
boolean fill)
Establishes a new foreground or fill color.
|
void |
setColor(java.awt.Color col,
boolean fill,
PDFStream stream)
Establishes a new foreground or fill color.
|
protected void |
setColor(java.awt.Color col,
boolean fill,
java.lang.StringBuffer pdf)
Establishes a new foreground or fill color.
|
void |
updateCharacterSpacing(float value)
Sets the current character spacing (Tc) value.
|
void |
updateColor(java.awt.Color col,
boolean fill,
java.lang.StringBuffer pdf)
Establishes a new foreground or fill color.
|
void |
updateLineWidth(float width)
Sets the current line width in points.
|
protected static final boolean WRITE_COMMENTS
protected PDFPaintingState currentState
protected PDFTextUtil textutil
public PDFContentGenerator(PDFDocument document, java.io.OutputStream out, PDFResourceContext resourceContext)
document
- the PDF documentout
- the output stream the PDF document is generated toresourceContext
- the resource contextpublic PDFDocument getDocument()
public java.io.OutputStream getOutputStream()
public PDFResourceContext getResourceContext()
public PDFStream getStream()
PDFStream
associated with this instance.public PDFPaintingState getState()
PDFState
associated with this instance.public PDFTextUtil getTextUtil()
PDFTextUtil
associated with this instance.public void flushPDFDoc() throws java.io.IOException
java.io.IOException
- if an error occurs while flushing the PDF objectsprotected void comment(java.lang.String text)
text
- text for the commentprotected void saveGraphicsState()
protected void saveGraphicsState(java.lang.String structElemType, int sequenceNum)
protected void beginMarkedContentSequence(java.lang.String structElemType, int mcid)
structElemType
- Structure Element Typemcid
- Sequence numberprotected void restoreGraphicsState(boolean popState)
saveGraphicsState()
.popState
- true if the state should also be popped, false if only the PDF command
should be issuedprotected void restoreGraphicsState()
restoreGraphicsState(boolean)
, with true
as
a parameter.protected void restoreGraphicsStateAccess()
restoreGraphicsState()
, additionally ending the current
marked content sequence if any.protected void separateTextElements(java.lang.String structElemType, int mcid)
structElemType
- structure element typemcid
- sequence numberbeginMarkedContentSequence(String, int)
protected void beginTextObject()
protected void beginTextObject(java.lang.String structElemType, int mcid)
structElemType
- structure element typemcid
- sequence numberbeginTextObject()
,
beginMarkedContentSequence(String, int)
protected void endTextObject()
public void concatenate(java.awt.geom.AffineTransform transform)
transform
- the transformation matrix (in points)public void clipRect(java.awt.Rectangle rect)
rect
- the clip rectanglepublic void add(java.lang.String content)
content
- the PDF contentpublic static final java.lang.String format(float value)
value
- the valuepublic void updateLineWidth(float width)
width
- line width in pointspublic void updateCharacterSpacing(float value)
value
- the Tc value (in unscaled text units)public void setColor(java.awt.Color col, boolean fill, PDFStream stream)
col
- the color to applyfill
- true to set the fill color, false for the foreground colorstream
- the PDFStream to write the PDF code topublic void setColor(java.awt.Color col, boolean fill)
col
- the color to applyfill
- true to set the fill color, false for the foreground colorprotected void setColor(java.awt.Color col, boolean fill, java.lang.StringBuffer pdf)
col
- the color to applyfill
- true to set the fill color, false for the foreground colorpdf
- StringBuffer to write the PDF code to, if null, the code is
written to the current stream.public void updateColor(java.awt.Color col, boolean fill, java.lang.StringBuffer pdf)
col
- the color to apply (null skips this operation)fill
- true to set the fill color, false for the foreground colorpdf
- StringBuffer to write the PDF code to, if null, the code is
written to the current stream.public void placeImage(float x, float y, float w, float h, PDFXObject xobj)
x
- X coordinatey
- Y coordinatew
- width for imageh
- height for imagexobj
- the image XObjectpublic void placeImage(float x, float y, float w, float h, PDFXObject xobj, java.lang.String structElemType, int mcid)
x
- X coordinatey
- Y coordinatew
- width for imageh
- height for imagexobj
- the image XObjectstructElemType
- structure element typemcid
- sequence numberbeginMarkedContentSequence(String, int)
Copyright 1999-2010 The Apache Software Foundation. All Rights Reserved.