public class CSContent extends Object
A PDF rendering program is a sequence of operations, each build by a list of operands followed by the operator.
Any visual appearance in a PDF document is build on a content stream. For example a PDPage hosts a content stream (or a list of content streams) to define its appearance.
A content stream has no access to indirect objects, this means object references are not valid operands for operations. Complex objects are used within a content stream via an indirection defined in a resource dictionary.
The CSContent itself is decoupled from its source of creation, this
means after manipulating the content stream you have to apply it where you
want to (for example adding it to a page).
You can work on the content stream directly, adding and removing operations.
A more elegant way to manipulate this is using a CSCreator, providing
high level methods for the different content stream operations.
| Modifier and Type | Method and Description |
|---|---|
void |
addMarkedContent(COSName mark,
byte[] content)
Add "content" at the end of the "marked content" portion in the content
stream of this.
|
void |
addOperation(CSOperation op)
Add another operation to the rendering program.
|
void |
addOperation(int index,
CSOperation op)
Add another operation to the rendering program.
|
static CSContent |
createFromBytes(byte[] data)
Create
CSContent from a byte array containing a PDF content
stream. |
static CSContent |
createFromCos(COSArray streams)
|
static CSContent |
createFromCos(COSStream stream)
|
static CSContent |
createNew()
Create a new
CSContent. |
COSStream |
createStream() |
COSStream |
createStreamFlate() |
CSOperation |
getLastOperation()
remove last operation from the rendering program.
|
CSOperation |
getOperation(int index) |
CSOperation[] |
getOperations() |
void |
removeLastOperation()
remove last operation from the rendering program.
|
void |
removeOperation(int index) |
void |
setMarkedContent(COSName mark,
byte[] content)
Set the "marked content" portion in the content stream of this.
|
int |
size()
The number of operations in the content stream.
|
byte[] |
toByteArray()
Create the byte representation from the list of operations.
|
String |
toString() |
public static CSContent createFromBytes(byte[] data)
CSContent from a byte array containing a PDF content
stream.data - The bytes defining the PDF content stream.CSContentpublic static CSContent createFromCos(COSStream stream)
stream - The stream defining containing the PDF content stream.CSContentpublic void addMarkedContent(COSName mark, byte[] content)
mark - The type of marked content we searchcontent - The content we want to use.public void addOperation(CSOperation op)
op - The new operation to append.public void addOperation(int index,
CSOperation op)
op - The new operation to append.public COSStream createStream()
public COSStream createStreamFlate()
public CSOperation getLastOperation()
public CSOperation getOperation(int index)
public CSOperation[] getOperations()
public void removeLastOperation()
public void removeOperation(int index)
public void setMarkedContent(COSName mark, byte[] content)
The portion between the marks is replaced with content.If no
marks are found, the new content is appended as a marked content section.
mark - The type of marked content we searchcontent - The content we want to use.public int size()
public byte[] toByteArray()
Copyright © 2013 intarsys consulting GmbH. All Rights Reserved.