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 efficientprotected Path currentPath
protected boolean isClip
protected int clippingRule
public PdfCanvasProcessor(IEventListener eventListener)
eventListener
- the IEventListener
that will receive rendering notificationspublic PdfCanvasProcessor(IEventListener eventListener, Map<String,IContentOperator> additionalContentOperators)
eventListener
- the IEventListener
that will receive rendering notificationsadditionalContentOperators
- an optional map of custom IContentOperator
s for rendering instructionspublic IXObjectDoHandler registerXObjectDoHandler(PdfName xobjectSubType, IXObjectDoHandler handler)
xobjectSubType
- the XObject subtype this handler will process, or PdfName.DEFAULT for a catch-all handlerhandler
- the handler that will receive notification when the Do operator for the specified subtype is encounteredpublic IContentOperator registerContentOperator(String operatorString, IContentOperator operator)
operatorString
- the operator id, or DEFAULT_OPERATOR for a catch-all operatoroperator
- the operator that will receive notification when the operator is encounteredpublic 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 streamresources
- the resources of the content stream. Must not be null.public void processPageContent(PdfPage page)
PdfCanvasProcessor
, you must call reset()
page
- the page to processpublic 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 operatoroperands
- a list with operandsprotected 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
- the font dictionary
to create the font fromprotected void beginMarkedContent(PdfName tag, PdfDictionary dict)
tag
- the tag of the marked contentdict
- the PdfDictionary associated with the marked contentprotected void endMarkedContent()
protected void eventOccurred(IEventData data, EventType type)
data
- event datatype
- event typeCopyright © 1998–2023 Apryse Group NV. All rights reserved.