Table of Contents

Class PdfCanvas

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

PdfCanvas class represents an algorithm for writing data into content stream.

public class PdfCanvas
Inheritance
PdfCanvas
Derived
Inherited Members

Remarks

PdfCanvas class represents an algorithm for writing data into content stream. To write into page content, create PdfCanvas from a page instance. To write into form XObject, create PdfCanvas from a form XObject instance. Make sure to call PdfCanvas.release() after you finished writing to the canvas. It will save some memory.

Constructors

PdfCanvas(PdfDocument, int)

Convenience method for fast PdfCanvas creation by a certain page.

public PdfCanvas(PdfDocument doc, int pageNum)

Parameters

doc PdfDocument

The document

pageNum int

The page number

PdfCanvas(PdfPage)

Convenience method for fast PdfCanvas creation by a certain page.

public PdfCanvas(PdfPage page)

Parameters

page PdfPage

page to create canvas from.

PdfCanvas(PdfPage, bool)

Convenience method for fast PdfCanvas creation by a certain page.

public PdfCanvas(PdfPage page, bool wrapOldContent)

Parameters

page PdfPage

page to create canvas from.

wrapOldContent bool

true to wrap all old content streams into q/Q operators so that the state of old content streams would not affect the new one

PdfCanvas(PdfStream, PdfResources, PdfDocument)

Creates PdfCanvas from content stream of page, form XObject, pattern etc.

public PdfCanvas(PdfStream contentStream, PdfResources resources, PdfDocument document)

Parameters

contentStream PdfStream

The content stream

resources PdfResources

The resources, a specialized dictionary that can be used by PDF instructions in the content stream

document PdfDocument

The document that the resulting content stream will be written to

PdfCanvas(PdfFormXObject, PdfDocument)

Creates a PdfCanvas from a PdfFormXObject.

public PdfCanvas(PdfFormXObject xObj, PdfDocument document)

Parameters

xObj PdfFormXObject

the PdfFormXObject used to create the PdfCanvas

document PdfDocument

the document to which the resulting content stream will be written

Fields

contentStream

the content stream for this canvas object.

protected PdfStream contentStream

Field Value

PdfStream

currentGs

the current graphics state.

protected CanvasGraphicsState currentGs

Field Value

CanvasGraphicsState

document

the document that the resulting content stream of this canvas will be written to.

protected PdfDocument document

Field Value

PdfDocument

drawingOnPage

protected bool drawingOnPage

Field Value

bool

gsStack

a LIFO stack of graphics state saved states.

protected Stack<CanvasGraphicsState> gsStack

Field Value

Stack<CanvasGraphicsState>

layerDepth

The list where we save/restore the layer depth.

protected IList<int> layerDepth

Field Value

IList<int>

mcDepth

a counter variable for the marked content stack.

protected int mcDepth

Field Value

int

resources

the resources for the page that this canvas belongs to.

protected PdfResources resources

Field Value

PdfResources
See Also

Methods

AddImageAt(ImageData, float, float, bool)

Creates PdfImageXObject from image and adds it to the specified position.

public virtual PdfXObject AddImageAt(ImageData image, float x, float y, bool asInline)

Parameters

image ImageData

the image from which PdfImageXObject will be created

x float

the horizontal position of the imageXObject

y float

the vertical position of the imageXObject

asInline bool

true if to add image as in-line

Returns

PdfXObject

the created imageXObject or null in case of in-line image (asInline = true)

AddImageFittedIntoRectangle(ImageData, Rectangle, bool)

Creates PdfImageXObject from image and fitted into specific rectangle on canvas.

public virtual PdfXObject AddImageFittedIntoRectangle(ImageData image, Rectangle rect, bool asInline)

Parameters

image ImageData

the image from which PdfImageXObject will be created

rect Rectangle

the rectangle in which the created imageXObject will be fit

asInline bool

true if to add image as in-line

Returns

PdfXObject

the created imageXObject or null in case of in-line image (asInline = true)

Remarks

Creates PdfImageXObject from image and fitted into specific rectangle on canvas. The created imageXObject will be fit inside on the specified rectangle without preserving aspect ratio.

The x, y, width and height parameters of the rectangle will be used in concatenating the transformation matrix as operands.
See Also

AddImageWithTransformationMatrix(ImageData, float, float, float, float, float, float)

Creates PdfImageXObject from image and adds it to canvas.

public virtual PdfXObject AddImageWithTransformationMatrix(ImageData image, float a, float b, float c, float d, float e, float f)

Parameters

image ImageData

the image from which PdfImageXObject will be created

a float

an element of the transformation matrix

b float

an element of the transformation matrix

c float

an element of the transformation matrix

d float

an element of the transformation matrix

e float

an element of the transformation matrix

f float

an element of the transformation matrix

Returns

PdfXObject

the created imageXObject or null in case of in-line image (asInline = true)

Remarks

Creates PdfImageXObject from image and adds it to canvas.

The float arguments will be used in concatenating the transformation matrix as operands.
See Also

AddImageWithTransformationMatrix(ImageData, float, float, float, float, float, float, bool)

Creates PdfImageXObject from image and adds it to canvas.

public virtual PdfXObject AddImageWithTransformationMatrix(ImageData image, float a, float b, float c, float d, float e, float f, bool asInline)

Parameters

image ImageData

the image from which PdfImageXObject will be created

a float

an element of the transformation matrix

b float

an element of the transformation matrix

c float

an element of the transformation matrix

d float

an element of the transformation matrix

e float

an element of the transformation matrix

f float

an element of the transformation matrix

asInline bool

true if to add image as in-line

Returns

PdfXObject

the created imageXObject or null in case of in-line image (asInline = true)

Remarks

Creates PdfImageXObject from image and adds it to canvas.

The float arguments will be used in concatenating the transformation matrix as operands.
See Also

AddInlineImage(PdfImageXObject, float, float, float, float, float, float)

Adds PdfImageXObject to canvas.

protected virtual void AddInlineImage(PdfImageXObject imageXObject, float a, float b, float c, float d, float e, float f)

Parameters

imageXObject PdfImageXObject

the PdfImageXObject object

a float

an element of the transformation matrix

b float

an element of the transformation matrix

c float

an element of the transformation matrix

d float

an element of the transformation matrix

e float

an element of the transformation matrix

f float

an element of the transformation matrix

AddXObject(PdfXObject)

Adds PdfXObject on canvas.

public virtual PdfCanvas AddXObject(PdfXObject xObject)

Parameters

xObject PdfXObject

the xObject to add

Returns

PdfCanvas

the current canvas

Remarks

Adds PdfXObject on canvas.

Note: the PdfImageXObject will be placed at coordinates (0, 0) with its original width and height, the PdfFormXObject will be fitted in its bBox.

AddXObjectAt(PdfXObject, float, float)

Adds PdfXObject to the specified position.

public virtual PdfCanvas AddXObjectAt(PdfXObject xObject, float x, float y)

Parameters

xObject PdfXObject

the xObject to add

x float

the horizontal position of the xObject

y float

the vertical position of the xObject

Returns

PdfCanvas

the current canvas

AddXObjectFittedIntoRectangle(PdfXObject, Rectangle)

Adds PdfXObject fitted into specific rectangle on canvas.

public virtual PdfCanvas AddXObjectFittedIntoRectangle(PdfXObject xObject, Rectangle rect)

Parameters

xObject PdfXObject

the xObject to add

rect Rectangle

the rectangle in which the xObject will be fitted

Returns

PdfCanvas

the current canvas

See Also

AddXObjectWithTransformationMatrix(PdfXObject, float, float, float, float, float, float)

Adds PdfXObject to canvas.

public virtual PdfCanvas AddXObjectWithTransformationMatrix(PdfXObject xObject, float a, float b, float c, float d, float e, float f)

Parameters

xObject PdfXObject

the xObject to add

a float

an element of the transformation matrix

b float

an element of the transformation matrix

c float

an element of the transformation matrix

d float

an element of the transformation matrix

e float

an element of the transformation matrix

f float

an element of the transformation matrix

Returns

PdfCanvas

the current canvas

Remarks

Adds PdfXObject to canvas.

The float arguments will be used in concatenating the transformation matrix as operands.
See Also

Arc(double, double, double, double, double, double)

Draws a partial ellipse inscribed within the rectangle x1,y1,x2,y2, starting at startAng degrees and covering extent degrees.

public virtual PdfCanvas Arc(double x1, double y1, double x2, double y2, double startAng, double extent)

Parameters

x1 double

a corner of the enclosing rectangle.

y1 double

a corner of the enclosing rectangle.

x2 double

a corner of the enclosing rectangle.

y2 double

a corner of the enclosing rectangle.

startAng double

starting angle in degrees.

extent double

angle extent in degrees.

Returns

PdfCanvas

current canvas.

Remarks

Draws a partial ellipse inscribed within the rectangle x1,y1,x2,y2, starting at startAng degrees and covering extent degrees. Angles start with 0 to the right (+x) and increase counter-clockwise.

ArcContinuous(double, double, double, double, double, double)

Draws a partial ellipse with the preceding line to the start of the arc to prevent path broking.

public virtual PdfCanvas ArcContinuous(double x1, double y1, double x2, double y2, double startAng, double extent)

Parameters

x1 double

a corner of the enclosing rectangle

y1 double

a corner of the enclosing rectangle

x2 double

a corner of the enclosing rectangle

y2 double

a corner of the enclosing rectangle

startAng double

starting angle in degrees

extent double

angle extent in degrees

Returns

PdfCanvas

the current canvas

Remarks

Draws a partial ellipse with the preceding line to the start of the arc to prevent path broking. The target arc is inscribed within the rectangle x1,y1,x2,y2, starting at startAng degrees and covering extent degrees. Angles start with 0 to the right (+x) and increase counter-clockwise.

AttachContentStream(PdfStream)

Attaches new content stream to the canvas.

public virtual void AttachContentStream(PdfStream contentStream)

Parameters

contentStream PdfStream

a content stream to attach.

Remarks

Attaches new content stream to the canvas. This method is supposed to be used when you want to write in different PdfStream keeping context (gsStack, currentGs, ...) the same.

BeginLayer(IPdfOCG)

Begins a graphic block whose visibility is controlled by the layer.

public virtual PdfCanvas BeginLayer(IPdfOCG layer)

Parameters

layer IPdfOCG

The layer to begin

Returns

PdfCanvas

The edited canvas.

Remarks

Begins a graphic block whose visibility is controlled by the layer. Blocks can be nested. Each block must be terminated by an EndLayer() .

Note that nested layers with AddChild(PdfLayer) only require a single call to this method and a single call to EndLayer() ; all the nesting control is built in.

BeginMarkedContent(PdfName)

Manually start a Marked Content sequence.

public virtual PdfCanvas BeginMarkedContent(PdfName tag)

Parameters

tag PdfName

the type of content contained

Returns

PdfCanvas

current canvas

Remarks

Manually start a Marked Content sequence. Used primarily for Tagged PDF

BeginMarkedContent(PdfName, PdfDictionary)

Manually start a Marked Content sequence with properties.

public virtual PdfCanvas BeginMarkedContent(PdfName tag, PdfDictionary properties)

Parameters

tag PdfName

the type of content that will be contained

properties PdfDictionary

the properties of the content, including Marked Content ID. If null, the PDF marker is BMC, else it is BDC

Returns

PdfCanvas

current canvas

Remarks

Manually start a Marked Content sequence with properties. Used primarily for Tagged PDF

BeginText()

Begins text block (PDF BT operator).

public virtual PdfCanvas BeginText()

Returns

PdfCanvas

current canvas.

BeginVariableText()

Begins variable text block

public virtual PdfCanvas BeginVariableText()

Returns

PdfCanvas

current canvas

BezierArc(double, double, double, double, double, double)

Generates an array of bezier curves to draw an arc.

public static IList<double[]> BezierArc(double x1, double y1, double x2, double y2, double startAng, double extent)

Parameters

x1 double

a corner of the enclosing rectangle.

y1 double

a corner of the enclosing rectangle.

x2 double

a corner of the enclosing rectangle.

y2 double

a corner of the enclosing rectangle.

startAng double

starting angle in degrees.

extent double

angle extent in degrees.

Returns

IList<double[]>

a list of double[] with the bezier curves.

Remarks

Generates an array of bezier curves to draw an arc.
(x1, y1) and (x2, y2) are the corners of the enclosing rectangle. Angles, measured in degrees, start with 0 to the right (the positive X axis) and increase counter-clockwise. The arc extends from startAng to startAng+extent. i.e. startAng=0 and extent=180 yields an openside-down semi-circle.
The resulting coordinates are of the form double[]{x1,y1,x2,y2,x3,y3, x4,y4} such that the curve goes from (x1, y1) to (x4, y4) with (x2, y2) and (x3, y3) as their respective Bezier control points.
Note: this code was taken from ReportLab (www.reportlab.org), an excellent PDF generator for Python (BSD license: http://www.reportlab.org/devfaq.html#1.3 ).

Circle(double, double, double)

Draws a circle.

public virtual PdfCanvas Circle(double x, double y, double r)

Parameters

x double

x center of circle.

y double

y center of circle.

r double

radius of circle.

Returns

PdfCanvas

current canvas.

Remarks

Draws a circle. The endpoint will (x+r, y).

Clip()

Modify the current clipping path by intersecting it with the current path, using the nonzero winding rule to determine which regions lie inside the clipping path.

public virtual PdfCanvas Clip()

Returns

PdfCanvas

current canvas.

ClosePath()

Closes the current subpath by appending a straight line segment from the current point to the starting point of the subpath.

public virtual PdfCanvas ClosePath()

Returns

PdfCanvas

current canvas.

ClosePathEoFillStroke()

Closes the path, fills it using the even-odd rule to determine the region to fill and strokes it.

public virtual PdfCanvas ClosePathEoFillStroke()

Returns

PdfCanvas

current canvas.

ClosePathFillStroke()

Closes the path, fills it using the non-zero winding number rule to determine the region to fill and strokes it.

public virtual PdfCanvas ClosePathFillStroke()

Returns

PdfCanvas

current canvas.

ClosePathStroke()

Closes the path and strokes it.

public virtual PdfCanvas ClosePathStroke()

Returns

PdfCanvas

current canvas.

CloseTag()

Manually close a tag, ending a Marked Content sequence.

public virtual PdfCanvas CloseTag()

Returns

PdfCanvas

current canvas

Remarks

Manually close a tag, ending a Marked Content sequence. Used primarily for Tagged PDF

ConcatMatrix(double, double, double, double, double, double)

Concatenates the 2x3 affine transformation matrix to the current matrix in the content stream managed by this Canvas.

public virtual PdfCanvas ConcatMatrix(double a, double b, double c, double d, double e, double f)

Parameters

a double

operand 1,1 in the matrix.

b double

operand 1,2 in the matrix.

c double

operand 2,1 in the matrix.

d double

operand 2,2 in the matrix.

e double

operand 3,1 in the matrix.

f double

operand 3,2 in the matrix.

Returns

PdfCanvas

current canvas

Remarks

Concatenates the 2x3 affine transformation matrix to the current matrix in the content stream managed by this Canvas. Contrast with SetTextMatrix(AffineTransform)

ConcatMatrix(AffineTransform)

Concatenates the affine transformation matrix to the current matrix in the content stream managed by this Canvas.

public virtual PdfCanvas ConcatMatrix(AffineTransform transform)

Parameters

transform AffineTransform

affine transformation matrix to be concatenated to the current matrix

Returns

PdfCanvas

current canvas

See Also

ConcatMatrix(PdfArray)

Concatenates the 2x3 affine transformation matrix to the current matrix in the content stream managed by this Canvas.

public virtual PdfCanvas ConcatMatrix(PdfArray array)

Parameters

array PdfArray

affine transformation stored as a PdfArray with 6 values

Returns

PdfCanvas

current canvas

Remarks

Concatenates the 2x3 affine transformation matrix to the current matrix in the content stream managed by this Canvas. If an array not containing the 6 values of the matrix is passed, The current canvas is returned unchanged.

CurveFromTo(double, double, double, double)

Appends a Bezier curve to the path, starting from the current point.

public virtual PdfCanvas CurveFromTo(double x1, double y1, double x3, double y3)

Parameters

x1 double

x coordinate of the first control point.

y1 double

y coordinate of the first control point.

x3 double

x coordinate of the ending point.

y3 double

y coordinate of the ending point.

Returns

PdfCanvas

current canvas.

CurveTo(double, double, double, double)

Appends a Bezier curve to the path, starting from the current point.

public virtual PdfCanvas CurveTo(double x2, double y2, double x3, double y3)

Parameters

x2 double

x coordinate of the second control point.

y2 double

y coordinate of the second control point.

x3 double

x coordinate of the ending point.

y3 double

y coordinate of the ending point.

Returns

PdfCanvas

current canvas.

CurveTo(double, double, double, double, double, double)

Appends a B&#xea;zier curve to the path, starting from the current point.

public virtual PdfCanvas CurveTo(double x1, double y1, double x2, double y2, double x3, double y3)

Parameters

x1 double

x coordinate of the first control point.

y1 double

y coordinate of the first control point.

x2 double

x coordinate of the second control point.

y2 double

y coordinate of the second control point.

x3 double

x coordinate of the ending point.

y3 double

y coordinate of the ending point.

Returns

PdfCanvas

current canvas.

Ellipse(double, double, double, double)

Draws an ellipse inscribed within the rectangle x1,y1,x2,y2.

public virtual PdfCanvas Ellipse(double x1, double y1, double x2, double y2)

Parameters

x1 double

a corner of the enclosing rectangle

y1 double

a corner of the enclosing rectangle

x2 double

a corner of the enclosing rectangle

y2 double

a corner of the enclosing rectangle

Returns

PdfCanvas

current canvas.

EndLayer()

Ends OCG layer.

public virtual PdfCanvas EndLayer()

Returns

PdfCanvas

current canvas.

EndMarkedContent()

Manually end a Marked Content sequence.

public virtual PdfCanvas EndMarkedContent()

Returns

PdfCanvas

current canvas

Remarks

Manually end a Marked Content sequence. Used primarily for Tagged PDF

EndPath()

Ends the path without filling or stroking it.

public virtual PdfCanvas EndPath()

Returns

PdfCanvas

current canvas.

EndText()

Ends text block (PDF ET operator).

public virtual PdfCanvas EndText()

Returns

PdfCanvas

current canvas.

EndVariableText()

Ends variable text block

public virtual PdfCanvas EndVariableText()

Returns

PdfCanvas

current canvas

EoClip()

Modify the current clipping path by intersecting it with the current path, using the even-odd rule to determine which regions lie inside the clipping path.

public virtual PdfCanvas EoClip()

Returns

PdfCanvas

current canvas.

EoFill()

EOFills current path.

public virtual PdfCanvas EoFill()

Returns

PdfCanvas

current canvas.

EoFillStroke()

Fills the path, using the even-odd rule to determine the region to fill and strokes it.

public virtual PdfCanvas EoFillStroke()

Returns

PdfCanvas

current canvas.

Fill()

Fills current path.

public virtual PdfCanvas Fill()

Returns

PdfCanvas

current canvas.

FillStroke()

Fills the path using the non-zero winding number rule to determine the region to fill and strokes it.

public virtual PdfCanvas FillStroke()

Returns

PdfCanvas

current canvas.

GetContentStream()

Please, use this method with caution and only if you know what you are doing.

public virtual PdfStream GetContentStream()

Returns

PdfStream

the content stream to which this canvas object writes.

Remarks

Please, use this method with caution and only if you know what you are doing. Manipulating with underlying stream object of canvas could lead to corruption of it's data.

GetDocument()

Get the document this canvas belongs to

public virtual PdfDocument GetDocument()

Returns

PdfDocument

PdfDocument the document that this canvas belongs to

GetGraphicsState()

Gets current CanvasGraphicsState.

public virtual CanvasGraphicsState GetGraphicsState()

Returns

CanvasGraphicsState

container containing properties for the current state of the canvas.

GetResources()

Get the resources of the page that this canvas belongs to..

public virtual PdfResources GetResources()

Returns

PdfResources

PdfResources of the page that this canvas belongs to..

LineTo(double, double)

Appends a straight line segment from the current point (x, y).

public virtual PdfCanvas LineTo(double x, double y)

Parameters

x double

x coordinate.

y double

y coordinate.

Returns

PdfCanvas

current canvas.

Remarks

Appends a straight line segment from the current point (x, y). The new current point is (x, y).

MoveText(double, double)

Moves text by shifting text line matrix (PDF Td operator).

public virtual PdfCanvas MoveText(double x, double y)

Parameters

x double

x coordinate.

y double

y coordinate.

Returns

PdfCanvas

current canvas.

MoveTextWithLeading(float, float)

Moves to the start of the next line, offset from the start of the current line.

public virtual PdfCanvas MoveTextWithLeading(float x, float y)

Parameters

x float

offset of the new current point

y float

y-coordinate of the new current point

Returns

PdfCanvas

current canvas.

Remarks

Moves to the start of the next line, offset from the start of the current line.
As a side effect, this sets the leading parameter in the text state.

MoveTo(double, double)

Move the current point (x, y), omitting any connecting line segment.

public virtual PdfCanvas MoveTo(double x, double y)

Parameters

x double

x coordinate.

y double

y coordinate.

Returns

PdfCanvas

current canvas.

NewlineShowText(float, float, string)

Moves to the next line and shows text string, using the given values of the character and word spacing parameters.

public virtual PdfCanvas NewlineShowText(float wordSpacing, float charSpacing, string text)

Parameters

wordSpacing float

a parameter

charSpacing float

a parameter

text string

the text to write

Returns

PdfCanvas

current canvas.

NewlineShowText(string)

Moves to the next line and shows text.

public virtual PdfCanvas NewlineShowText(string text)

Parameters

text string

the text to write

Returns

PdfCanvas

current canvas.

NewlineText()

Moves to the start of the next line.

public virtual PdfCanvas NewlineText()

Returns

PdfCanvas

current canvas.

OpenTag(CanvasTag)

Manually open a canvas tag, beginning a Marked Content sequence.

public virtual PdfCanvas OpenTag(CanvasTag tag)

Parameters

tag CanvasTag

the type of content that will be contained

Returns

PdfCanvas

current canvas

Remarks

Manually open a canvas tag, beginning a Marked Content sequence. Used primarily for Tagged PDF

OpenTag(TagReference)

Open a tag, beginning a Marked Content sequence.

public virtual PdfCanvas OpenTag(TagReference tagReference)

Parameters

tagReference TagReference

reference to the tag from the document logical structure

Returns

PdfCanvas

current canvas

Remarks

Open a tag, beginning a Marked Content sequence. This MC sequence will belong to the tag from the document logical structure.
CanvasTag will be automatically created with assigned mcid(Marked Content id) to it. Mcid serves as a reference between Marked Content sequence and logical structure element.

PaintShading(PdfShading)

Paints a shading object and adds it to the resources of this canvas

public virtual PdfCanvas PaintShading(PdfShading shading)

Parameters

shading PdfShading

a shading object to be painted

Returns

PdfCanvas

current canvas.

Rectangle(double, double, double, double)

Draws a rectangle.

public virtual PdfCanvas Rectangle(double x, double y, double width, double height)

Parameters

x double

x coordinate of the starting point.

y double

y coordinate of the starting point.

width double

width.

height double

height.

Returns

PdfCanvas

current canvas.

Rectangle(Rectangle)

Draws a rectangle.

public virtual PdfCanvas Rectangle(Rectangle rectangle)

Parameters

rectangle Rectangle

a rectangle to be drawn

Returns

PdfCanvas

current canvas.

Release()

Releases the canvas.

public virtual void Release()

Remarks

Releases the canvas. Use this method after you finished working with canvas.

ResetFillColorCmyk()

Changes the current color for filling paths to black.

public virtual PdfCanvas ResetFillColorCmyk()

Returns

PdfCanvas

current canvas.

ResetFillColorGray()

Changes the current color for filling paths to black.

public virtual PdfCanvas ResetFillColorGray()

Returns

PdfCanvas

current canvas.

ResetFillColorRgb()

Changes the current color for filling paths to black.

public virtual PdfCanvas ResetFillColorRgb()

Returns

PdfCanvas

current canvas.

ResetStrokeColorCmyk()

Changes the current color for stroking paths to black.

public virtual PdfCanvas ResetStrokeColorCmyk()

Returns

PdfCanvas

current canvas.

ResetStrokeColorGray()

Changes the current color for stroking paths to black.

public virtual PdfCanvas ResetStrokeColorGray()

Returns

PdfCanvas

current canvas.

ResetStrokeColorRgb()

Changes the current color for stroking paths to black.

public virtual PdfCanvas ResetStrokeColorRgb()

Returns

PdfCanvas

current canvas.

RestoreState()

Restores graphics state.

public virtual PdfCanvas RestoreState()

Returns

PdfCanvas

current canvas.

RoundRectangle(double, double, double, double, double)

Draws rounded rectangle.

public virtual PdfCanvas RoundRectangle(double x, double y, double width, double height, double radius)

Parameters

x double

x coordinate of the starting point.

y double

y coordinate of the starting point.

width double

width.

height double

height.

radius double

radius of the arc corner.

Returns

PdfCanvas

current canvas.

SaveState()

Saves graphics state.

public virtual PdfCanvas SaveState()

Returns

PdfCanvas

current canvas.

SetCharacterSpacing(float)

Sets the character spacing parameter.

public virtual PdfCanvas SetCharacterSpacing(float charSpacing)

Parameters

charSpacing float

a parameter

Returns

PdfCanvas

current canvas.

SetColor(Color, bool)

Changes the current color for paths.

public virtual PdfCanvas SetColor(Color color, bool fill)

Parameters

color Color

the new color.

fill bool

set fill color (true) or stroke color (false)

Returns

PdfCanvas

current canvas.

SetColor(PdfColorSpace, float[], bool)

Changes the current color for paths.

public virtual PdfCanvas SetColor(PdfColorSpace colorSpace, float[] colorValue, bool fill)

Parameters

colorSpace PdfColorSpace

the color space of the new color

colorValue float[]

a list of numerical values with a length corresponding to the specs of the color space. Values should be in the range [0,1]

fill bool

set fill color (true) or stroke color (false)

Returns

PdfCanvas

current canvas.

SetColor(PdfColorSpace, float[], PdfPattern, bool)

Changes the current color for paths with an explicitly defined pattern.

public virtual PdfCanvas SetColor(PdfColorSpace colorSpace, float[] colorValue, PdfPattern pattern, bool fill)

Parameters

colorSpace PdfColorSpace

the color space of the new color

colorValue float[]

a list of numerical values with a length corresponding to the specs of the color space. Values should be in the range [0,1]

pattern PdfPattern

a pattern for the colored line or area

fill bool

set fill color (true) or stroke color (false)

Returns

PdfCanvas

current canvas.

SetDrawingOnPage(bool)

Sets whether we are currently drawing on a page.

public virtual void SetDrawingOnPage(bool drawingOnPage)

Parameters

drawingOnPage bool

true if we are currently drawing on page false if not

SetExtGState(PdfExtGState)

Sets the ExtGState dictionary for the current graphics state

public virtual PdfCanvas SetExtGState(PdfExtGState extGState)

Parameters

extGState PdfExtGState

a dictionary that maps resource names to graphics state parameter dictionaries

Returns

PdfCanvas

current canvas.

SetExtGState(PdfDictionary)

Sets the ExtGState dictionary for the current graphics state

public virtual PdfExtGState SetExtGState(PdfDictionary extGState)

Parameters

extGState PdfDictionary

a dictionary that maps resource names to graphics state parameter dictionaries

Returns

PdfExtGState

current canvas.

SetFillColor(Color)

Changes the current color for filling paths.

public virtual PdfCanvas SetFillColor(Color color)

Parameters

color Color

fill color.

Returns

PdfCanvas

current canvas.

SetFillColorCmyk(float, float, float, float)

Changes the current color for filling paths to a CMYK value.

public virtual PdfCanvas SetFillColorCmyk(float c, float m, float y, float k)

Parameters

c float

a cyan value in the range [0,1]

m float

a magenta value in the range [0,1]

y float

a yellow value in the range [0,1]

k float

a key (black) value in the range [0,1]

Returns

PdfCanvas

current canvas.

SetFillColorGray(float)

Changes the current color for filling paths to a grayscale value.

public virtual PdfCanvas SetFillColorGray(float g)

Parameters

g float

a grayscale value in the range [0,1]

Returns

PdfCanvas

current canvas.

SetFillColorRgb(float, float, float)

Changes the current color for filling paths to an RGB value.

public virtual PdfCanvas SetFillColorRgb(float r, float g, float b)

Parameters

r float

a red value in the range [0,1]

g float

a green value in the range [0,1]

b float

a blue value in the range [0,1]

Returns

PdfCanvas

current canvas.

SetFillColorShading(Shading)

Adds or changes the shading of the current fill color path.

public virtual PdfCanvas SetFillColorShading(PdfPattern.Shading shading)

Parameters

shading PdfPattern.Shading

the shading

Returns

PdfCanvas

current canvas.

SetFlatnessTolerance(float)

Changes the Flatness.

public virtual PdfCanvas SetFlatnessTolerance(float flatnessTolerance)

Parameters

flatnessTolerance float

a value

Returns

PdfCanvas

current canvas.

Remarks

Changes the Flatness.

Flatness sets the maximum permitted distance in device pixels between the mathematically correct path and an approximation constructed from straight line segments.

SetFontAndSize(PdfFont, float)

Sets font and size (PDF Tf operator).

public virtual PdfCanvas SetFontAndSize(PdfFont font, float size)

Parameters

font PdfFont

The font

size float

The font size.

Returns

PdfCanvas

The edited canvas.

SetHorizontalScaling(float)

Sets the horizontal scaling parameter.

public virtual PdfCanvas SetHorizontalScaling(float scale)

Parameters

scale float

a parameter.

Returns

PdfCanvas

current canvas.

SetLeading(float)

Sets the text leading parameter.

public virtual PdfCanvas SetLeading(float leading)

Parameters

leading float

the new leading.

Returns

PdfCanvas

current canvas.

Remarks

Sets the text leading parameter.
The leading parameter is measured in text space units. It specifies the vertical distance between the baselines of adjacent lines of text.

SetLineCapStyle(int)

Sets the line cap style, the shape to be used at the ends of open subpaths when they are stroked.

public virtual PdfCanvas SetLineCapStyle(int lineCapStyle)

Parameters

lineCapStyle int

a line cap style to be set

Returns

PdfCanvas

current canvas.

SetLineDash(float)

Changes the value of the line dash pattern.

public virtual PdfCanvas SetLineDash(float phase)

Parameters

phase float

the value of the phase

Returns

PdfCanvas

current canvas.

Remarks

Changes the value of the line dash pattern.
The line dash pattern controls the pattern of dashes and gaps used to stroke paths. It is specified by an array and a phase. The array specifies the length of the alternating dashes and gaps. The phase specifies the distance into the dash pattern to start the dash.

SetLineDash(float, float)

Changes the value of the line dash pattern.

public virtual PdfCanvas SetLineDash(float unitsOn, float phase)

Parameters

unitsOn float

the number of units that must be 'on' (equals the number of units that must be 'off').

phase float

the value of the phase

Returns

PdfCanvas

current canvas.

Remarks

Changes the value of the line dash pattern.
The line dash pattern controls the pattern of dashes and gaps used to stroke paths. It is specified by an array and a phase. The array specifies the length of the alternating dashes and gaps. The phase specifies the distance into the dash pattern to start the dash.

SetLineDash(float, float, float)

Changes the value of the line dash pattern.

public virtual PdfCanvas SetLineDash(float unitsOn, float unitsOff, float phase)

Parameters

unitsOn float

the number of units that must be 'on'

unitsOff float

the number of units that must be 'off'

phase float

the value of the phase

Returns

PdfCanvas

current canvas.

Remarks

Changes the value of the line dash pattern.
The line dash pattern controls the pattern of dashes and gaps used to stroke paths. It is specified by an array and a phase. The array specifies the length of the alternating dashes and gaps. The phase specifies the distance into the dash pattern to start the dash.

SetLineDash(float[], float)

Changes the value of the line dash pattern.

public virtual PdfCanvas SetLineDash(float[] array, float phase)

Parameters

array float[]

length of the alternating dashes and gaps

phase float

the value of the phase

Returns

PdfCanvas

current canvas.

Remarks

Changes the value of the line dash pattern.
The line dash pattern controls the pattern of dashes and gaps used to stroke paths. It is specified by an array and a phase. The array specifies the length of the alternating dashes and gaps. The phase specifies the distance into the dash pattern to start the dash.

SetLineJoinStyle(int)

Sets the line join style, the shape to be used at the corners of paths when they are stroked.

public virtual PdfCanvas SetLineJoinStyle(int lineJoinStyle)

Parameters

lineJoinStyle int

a line join style to be set

Returns

PdfCanvas

current canvas.

SetLineWidth(float)

Sets line width.

public virtual PdfCanvas SetLineWidth(float lineWidth)

Parameters

lineWidth float

line width.

Returns

PdfCanvas

current canvas.

SetMiterLimit(float)

Sets the miter limit, a parameter specifying the maximum length a miter join may extend beyond the join point, relative to the angle of the line segments.

public virtual PdfCanvas SetMiterLimit(float miterLimit)

Parameters

miterLimit float

a miter limit to be set

Returns

PdfCanvas

current canvas.

SetRenderingIntent(PdfName)

Set the rendering intent.

public virtual PdfCanvas SetRenderingIntent(PdfName renderingIntent)

Parameters

renderingIntent PdfName

a PdfName containing a color metric

Returns

PdfCanvas

current canvas.

Remarks

Set the rendering intent. possible values are: PdfName.AbsoluteColorimetric, PdfName.RelativeColorimetric, PdfName.Saturation, PdfName.Perceptual.

SetStrokeColor(Color)

Changes the current color for stroking paths.

public virtual PdfCanvas SetStrokeColor(Color color)

Parameters

color Color

stroke color.

Returns

PdfCanvas

current canvas.

SetStrokeColorCmyk(float, float, float, float)

Changes the current color for stroking paths to a CMYK value.

public virtual PdfCanvas SetStrokeColorCmyk(float c, float m, float y, float k)

Parameters

c float

a cyan value in the range [0,1]

m float

a magenta value in the range [0,1]

y float

a yellow value in the range [0,1]

k float

a key (black) value in the range [0,1]

Returns

PdfCanvas

current canvas.

SetStrokeColorGray(float)

Changes the current color for stroking paths to a grayscale value.

public virtual PdfCanvas SetStrokeColorGray(float g)

Parameters

g float

a grayscale value in the range [0,1]

Returns

PdfCanvas

current canvas.

SetStrokeColorRgb(float, float, float)

Changes the current color for stroking paths to an RGB value.

public virtual PdfCanvas SetStrokeColorRgb(float r, float g, float b)

Parameters

r float

a red value in the range [0,1]

g float

a green value in the range [0,1]

b float

a blue value in the range [0,1]

Returns

PdfCanvas

current canvas.

SetStrokeColorShading(Shading)

Adds or changes the shading of the current stroke color path.

public virtual PdfCanvas SetStrokeColorShading(PdfPattern.Shading shading)

Parameters

shading PdfPattern.Shading

the shading

Returns

PdfCanvas

current canvas.

SetTextMatrix(float, float)

Changes the text matrix.

public virtual PdfCanvas SetTextMatrix(float x, float y)

Parameters

x float

operand 3,1 in the matrix.

y float

operand 3,2 in the matrix.

Returns

PdfCanvas

current canvas.

SetTextMatrix(float, float, float, float, float, float)

Replaces the text matrix.

public virtual PdfCanvas SetTextMatrix(float a, float b, float c, float d, float x, float y)

Parameters

a float

operand 1,1 in the matrix.

b float

operand 1,2 in the matrix.

c float

operand 2,1 in the matrix.

d float

operand 2,2 in the matrix.

x float

operand 3,1 in the matrix.

y float

operand 3,2 in the matrix.

Returns

PdfCanvas

current canvas.

Remarks

Replaces the text matrix. Contrast with ConcatMatrix(PdfArray)

SetTextMatrix(AffineTransform)

Replaces the text matrix.

public virtual PdfCanvas SetTextMatrix(AffineTransform transform)

Parameters

transform AffineTransform

new textmatrix as transformation

Returns

PdfCanvas

current canvas

Remarks

Replaces the text matrix. Contrast with ConcatMatrix(PdfArray)

SetTextRenderingMode(int)

Sets text rendering mode.

public virtual PdfCanvas SetTextRenderingMode(int textRenderingMode)

Parameters

textRenderingMode int

text rendering mode @see PdfCanvasConstants.

Returns

PdfCanvas

current canvas.

SetTextRise(float)

Sets the text rise parameter.

public virtual PdfCanvas SetTextRise(float textRise)

Parameters

textRise float

a parameter

Returns

PdfCanvas

current canvas.

Remarks

Sets the text rise parameter.
This allows to write text in subscript or superscript mode.

SetWordSpacing(float)

Sets the word spacing parameter.

public virtual PdfCanvas SetWordSpacing(float wordSpacing)

Parameters

wordSpacing float

a parameter

Returns

PdfCanvas

current canvas.

ShowText(string)

Shows text (operator Tj).

public virtual PdfCanvas ShowText(string text)

Parameters

text string

text to show.

Returns

PdfCanvas

current canvas.

ShowText(GlyphLine)

Shows text (operator Tj).

public virtual PdfCanvas ShowText(GlyphLine text)

Parameters

text GlyphLine

text to show.

Returns

PdfCanvas

current canvas.

ShowText(GlyphLine, IEnumerator<GlyphLinePart>)

Shows text (operator Tj).

public virtual PdfCanvas ShowText(GlyphLine text, IEnumerator<GlyphLine.GlyphLinePart> iterator)

Parameters

text GlyphLine

text to show.

iterator IEnumerator<GlyphLine.GlyphLinePart>

iterator over parts of the glyph line that should be wrapped into some marked content groups, e.g. /ActualText or /ReversedChars

Returns

PdfCanvas

current canvas.

ShowText(PdfArray)

Shows text (operator TJ)

public virtual PdfCanvas ShowText(PdfArray textArray)

Parameters

textArray PdfArray

the text array. Each element of array can be a string or a number. If the element is a string, this operator shows the string. If it is a number, the operator adjusts the text position by that amount. The number is expressed in thousandths of a unit of text space. This amount is subtracted from the current horizontal or vertical coordinate, depending on the writing mode.

Returns

PdfCanvas

current canvas.

Stroke()

Strokes the path.

public virtual PdfCanvas Stroke()

Returns

PdfCanvas

current canvas.

WriteLiteral(char)

Outputs a char directly to the content.

public virtual PdfCanvas WriteLiteral(char c)

Parameters

c char

the char

Returns

PdfCanvas

current canvas.

WriteLiteral(float)

Outputs a float directly to the content.

public virtual PdfCanvas WriteLiteral(float n)

Parameters

n float

the float

Returns

PdfCanvas

current canvas.

WriteLiteral(string)

Outputs a String directly to the content.

public virtual PdfCanvas WriteLiteral(string s)

Parameters

s string

the String

Returns

PdfCanvas

current canvas.