public class PdfCanvasProcessor extends Object
Modifier and Type | Class and Description |
---|---|
protected static class |
PdfCanvasProcessor.PopGraphicsStateOperator
A handler that implements operator (Q).
|
Modifier and Type | Field and Description |
---|---|
protected int |
clippingRule
Specifies the filling rule which should be applied while calculating new clipping path.
|
protected Path |
currentPath |
static String |
DEFAULT_OPERATOR |
protected IEventListener |
eventListener
Listener that will be notified of render events
|
protected boolean |
isClip
Indicates whether the current clipping path should be modified by intersecting it with the current path.
|
protected Set<EventType> |
supportedEvents
Cache supported events in case the user's IEventListener.getSupportedEvents() method is not very efficient
|
Constructor and Description |
---|
PdfCanvasProcessor(IEventListener eventListener)
Creates a new PDF Content Stream Processor that will send its output to the designated render listener.
|
PdfCanvasProcessor(IEventListener eventListener, Map<String,IContentOperator> additionalContentOperators)
Creates a new PDF Content Stream Processor that will send its output to the designated render listener.
|
Modifier and Type | Method and Description |
---|---|
protected void |
beginMarkedContent(PdfName tag, PdfDictionary dict)
Add to the marked content stack
|
protected void |
endMarkedContent()
Remove the latest marked content from the stack.
|
protected void |
eventOccurred(IEventData data, EventType type)
This is a proxy to pass only those events to the event listener which are supported by it.
|
IEventListener |
getEventListener()
Accessor method for the IEventListener object maintained in this class.
|
protected PdfFont |
getFont(PdfDictionary fontDict)
Creates a PdfFont object by a font dictionary.
|
ParserGraphicsState |
getGraphicsState()
Gets the current ParserGraphicsState
|
Collection<String> |
getRegisteredOperatorStrings()
Gets the Collection containing all the registered operators strings.
|
protected PdfResources |
getResources() |
protected PdfStream |
getXObjectStream(PdfName xobjectName) |
protected void |
invokeOperator(PdfLiteral operator, List<PdfObject> operands)
Invokes an operator.
|
protected void |
paintPath(int operation, int rule)
Displays the current path.
|
protected void |
populateOperators()
Loads all the supported graphics and text state operators in a map.
|
protected void |
populateXObjectDoHandlers() |
void |
processContent(byte[] contentBytes, PdfResources resources)
Processes PDF syntax.
|
void |
processPageContent(PdfPage page)
Processes PDF syntax.
|
IContentOperator |
registerContentOperator(String operatorString, IContentOperator operator)
Registers a content operator that will be called when the specified operator string is encountered during content processing.
|
IXObjectDoHandler |
registerXObjectDoHandler(PdfName xobjectSubType, IXObjectDoHandler handler)
Registers a Do handler that will be called when Do for the provided XObject subtype is encountered during content processing.
|
void |
reset()
Resets the graphics state stack, matrices and resources.
|
public static final String DEFAULT_OPERATOR
protected final IEventListener eventListener
protected final Set<EventType> supportedEvents
IEventListener.getSupportedEvents()
method is not very efficient
protected Path currentPath
protected boolean isClip
protected int clippingRule
public PdfCanvasProcessor(IEventListener eventListener)
eventListener
- the IEventListener
that will receive rendering notifications
public PdfCanvasProcessor(IEventListener eventListener, Map<String,IContentOperator> additionalContentOperators)
eventListener
- the IEventListener
that will receive rendering notifications
additionalContentOperators
- an optional map of custom IContentOperator
s for rendering instructions
public IXObjectDoHandler registerXObjectDoHandler(PdfName xobjectSubType, IXObjectDoHandler handler)
xobjectSubType
- the XObject subtype this handler will process, or PdfName.DEFAULT for a catch-all handler
handler
- the handler that will receive notification when the Do operator for the specified subtype is encountered
public IContentOperator registerContentOperator(String operatorString, IContentOperator operator)
operatorString
- the operator id, or DEFAULT_OPERATOR for a catch-all operator
operator
- the operator that will receive notification when the operator is encountered
public Collection<String> getRegisteredOperatorStrings()
Collection
containing all the registered operators strings.
Collection
containing all the registered operators strings.
public void reset()
public ParserGraphicsState getGraphicsState()
ParserGraphicsState
ParserGraphicsState
public void processContent(byte[] contentBytes, PdfResources resources)
PdfCanvasProcessor
, you must call reset()
contentBytes
- the bytes of a content stream
resources
- the resources of the content stream. Must not be null.
public void processPageContent(PdfPage page)
PdfCanvasProcessor
, you must call reset()
page
- the page to process
public IEventListener getEventListener()
IEventListener
object maintained in this class. Necessary for implementing custom ContentOperator implementations.
protected void populateOperators()
protected void paintPath(int operation, int rule)
operation
- One of the possible combinations of PathRenderInfo.STROKE
and PathRenderInfo.FILL
values or PathRenderInfo.NO_OP
rule
- Either PdfCanvasConstants.FillingRule.NONZERO_WINDING
or PdfCanvasConstants.FillingRule.EVEN_ODD
In case it isn't applicable pass any byte
value.
protected void invokeOperator(PdfLiteral operator, List<PdfObject> operands)
operator
- the PDF Syntax of the operator
operands
- a list with operands
protected PdfResources getResources()
protected void populateXObjectDoHandlers()
protected PdfFont getFont(PdfDictionary fontDict)
PdfFont
object by a font dictionary. The font may have been cached in case it is an indirect object.
fontDict
-
protected void beginMarkedContent(PdfName tag, PdfDictionary dict)
tag
- the tag of the marked content
dict
- the PdfDictionary associated with the marked content
protected void endMarkedContent()
protected void eventOccurred(IEventData data, EventType type)
data
- event data
type
- event type
Copyright © 1998–2018 iText Group NV. All rights reserved.