Table of Contents

Class PdfCanvasProcessor

Namespace
iText.Kernel.Pdf.Canvas.Parser
Assembly
itext.kernel.dll

Processor for a PDF content stream.

public class PdfCanvasProcessor
Inheritance
PdfCanvasProcessor
Inherited Members

Constructors

PdfCanvasProcessor(IEventListener)

Creates a new PDF Content Stream Processor that will send its output to the designated render listener.

public PdfCanvasProcessor(IEventListener eventListener)

Parameters

eventListener IEventListener

the IEventListener that will receive rendering notifications

PdfCanvasProcessor(IEventListener, IDictionary<string, IContentOperator>)

Creates a new PDF Content Stream Processor that will send its output to the designated render listener.

public PdfCanvasProcessor(IEventListener eventListener, IDictionary<string, IContentOperator> additionalContentOperators)

Parameters

eventListener IEventListener

the IEventListener that will receive rendering notifications

additionalContentOperators IDictionary<string, IContentOperator>

an optional map of custom IContentOperator s for rendering instructions

Remarks

Creates a new PDF Content Stream Processor that will send its output to the designated render listener. Also allows registration of custom IContentOperators that can influence how (and whether or not) the PDF instructions will be parsed.

Fields

DEFAULT_OPERATOR

public const string DEFAULT_OPERATOR = "DefaultOperator"

Field Value

string

clippingRule

Specifies the filling rule which should be applied while calculating new clipping path.

protected int clippingRule

Field Value

int

currentPath

protected Path currentPath

Field Value

Path

eventListener

Listener that will be notified of render events

protected readonly IEventListener eventListener

Field Value

IEventListener

isClip

Indicates whether the current clipping path should be modified by intersecting it with the current path.

protected bool isClip

Field Value

bool

supportedEvents

Cache supported events in case the user's GetSupportedEvents() method is not very efficient

protected readonly ICollection<EventType> supportedEvents

Field Value

ICollection<EventType>

Methods

BeginMarkedContent(PdfName, PdfDictionary)

Add to the marked content stack

protected virtual void BeginMarkedContent(PdfName tag, PdfDictionary dict)

Parameters

tag PdfName

the tag of the marked content

dict PdfDictionary

the PdfDictionary associated with the marked content

EndMarkedContent()

Remove the latest marked content from the stack.

protected virtual void EndMarkedContent()

Remarks

Remove the latest marked content from the stack. Keeps track of the BMC, BDC and EMC operators.

EventOccurred(IEventData, EventType)

This is a proxy to pass only those events to the event listener which are supported by it.

protected virtual void EventOccurred(IEventData data, EventType type)

Parameters

data IEventData

event data

type EventType

event type

GetEventListener()

Accessor method for the IEventListener object maintained in this class.

public virtual IEventListener GetEventListener()

Returns

IEventListener

the renderListener

Remarks

Accessor method for the IEventListener object maintained in this class. Necessary for implementing custom ContentOperator implementations.

GetFont(PdfDictionary)

Creates a PdfFont object by a font dictionary.

protected virtual PdfFont GetFont(PdfDictionary fontDict)

Parameters

fontDict PdfDictionary

the font dictionary to create the font from

Returns

PdfFont

the created font

Remarks

Creates a PdfFont object by a font dictionary. The font may have been cached in case it is an indirect object.

GetGraphicsState()

Gets the current ParserGraphicsState

public virtual ParserGraphicsState GetGraphicsState()

Returns

ParserGraphicsState

the current ParserGraphicsState

GetRegisteredOperatorStrings()

Gets the containing all the registered operators strings.

public virtual ICollection<string> GetRegisteredOperatorStrings()

Returns

ICollection<string>

containing all the registered operators strings.

GetResources()

protected virtual PdfResources GetResources()

Returns

PdfResources

GetXObjectStream(PdfName)

protected virtual PdfStream GetXObjectStream(PdfName xobjectName)

Parameters

xobjectName PdfName

Returns

PdfStream

InvokeOperator(PdfLiteral, IList<PdfObject>)

Invokes an operator.

protected virtual void InvokeOperator(PdfLiteral @operator, IList<PdfObject> operands)

Parameters

operator PdfLiteral

the PDF Syntax of the operator

operands IList<PdfObject>

a list with operands

PaintPath(int, int)

Displays the current path.

protected virtual void PaintPath(int operation, int rule)

Parameters

operation int

One of the possible combinations of STROKE and FILL values or NO_OP

rule int

Either NONZERO_WINDING or EVEN_ODD In case it isn't applicable pass any byte value.

PopulateOperators()

Loads all the supported graphics and text state operators in a map.

protected virtual void PopulateOperators()

PopulateXObjectDoHandlers()

protected virtual void PopulateXObjectDoHandlers()

ProcessContent(byte[], PdfResources)

Processes PDF syntax.

public virtual void ProcessContent(byte[] contentBytes, PdfResources resources)

Parameters

contentBytes byte[]

the bytes of a content stream

resources PdfResources

the resources of the content stream. Must not be null.

Remarks

Processes PDF syntax. Note: If you re-use a given PdfCanvasProcessor , you must call Reset()

ProcessPageContent(PdfPage)

Processes PDF syntax.

public virtual void ProcessPageContent(PdfPage page)

Parameters

page PdfPage

the page to process

Remarks

Processes PDF syntax. Note: If you re-use a given PdfCanvasProcessor , you must call Reset()

RegisterContentOperator(string, IContentOperator)

Registers a content operator that will be called when the specified operator string is encountered during content processing.

public virtual IContentOperator RegisterContentOperator(string operatorString, IContentOperator @operator)

Parameters

operatorString string

the operator id, or DEFAULT_OPERATOR for a catch-all operator

operator IContentOperator

the operator that will receive notification when the operator is encountered

Returns

IContentOperator

the existing registered operator, if any

Remarks

Registers a content operator that will be called when the specified operator string is encountered during content processing.
If you register an operator, it is a very good idea to pass the call on to the existing registered operator (returned by this call), otherwise you may inadvertently change the internal behavior of the processor.

RegisterXObjectDoHandler(PdfName, IXObjectDoHandler)

Registers a Do handler that will be called when Do for the provided XObject subtype is encountered during content processing.

public virtual IXObjectDoHandler RegisterXObjectDoHandler(PdfName xobjectSubType, IXObjectDoHandler handler)

Parameters

xobjectSubType PdfName

the XObject subtype this handler will process, or PdfName.DEFAULT for a catch-all handler

handler IXObjectDoHandler

the handler that will receive notification when the Do operator for the specified subtype is encountered

Returns

IXObjectDoHandler

the existing registered handler, if any

Remarks

Registers a Do handler that will be called when Do for the provided XObject subtype is encountered during content processing.
If you register a handler, it is a very good idea to pass the call on to the existing registered handler (returned by this call), otherwise you may inadvertently change the internal behavior of the processor.

Reset()

Resets the graphics state stack, matrices and resources.

public virtual void Reset()