Class PdfCanvas
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
PdfDocumentThe document
pageNum
intThe page number
PdfCanvas(PdfPage)
Convenience method for fast PdfCanvas creation by a certain page.
public PdfCanvas(PdfPage page)
Parameters
page
PdfPagepage 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
PdfPagepage to create canvas from.
wrapOldContent
booltrue 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
PdfStreamThe content stream
resources
PdfResourcesThe resources, a specialized dictionary that can be used by PDF instructions in the content stream
document
PdfDocumentThe 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
PdfFormXObjectthe PdfFormXObject used to create the PdfCanvas
document
PdfDocumentthe document to which the resulting content stream will be written
Fields
contentStream
the content stream for this canvas object.
protected PdfStream contentStream
Field Value
currentGs
the current graphics state.
protected CanvasGraphicsState currentGs
Field Value
document
the document that the resulting content stream of this canvas will be written to.
protected PdfDocument document
Field Value
drawingOnPage
protected bool drawingOnPage
Field Value
gsStack
a LIFO stack of graphics state saved states.
protected Stack<CanvasGraphicsState> gsStack
Field Value
layerDepth
The list where we save/restore the layer depth.
protected IList<int> layerDepth
Field Value
mcDepth
a counter variable for the marked content stack.
protected int mcDepth
Field Value
resources
the resources for the page that this canvas belongs to.
protected PdfResources resources
Field Value
- 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
ImageDatathe image from which PdfImageXObject will be created
x
floatthe horizontal position of the imageXObject
y
floatthe vertical position of the imageXObject
asInline
booltrue 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
ImageDatathe image from which PdfImageXObject will be created
rect
Rectanglethe rectangle in which the created imageXObject will be fit
asInline
booltrue 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
ImageDatathe image from which PdfImageXObject will be created
a
floatan element of the transformation matrix
b
floatan element of the transformation matrix
c
floatan element of the transformation matrix
d
floatan element of the transformation matrix
e
floatan element of the transformation matrix
f
floatan 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
ImageDatathe image from which PdfImageXObject will be created
a
floatan element of the transformation matrix
b
floatan element of the transformation matrix
c
floatan element of the transformation matrix
d
floatan element of the transformation matrix
e
floatan element of the transformation matrix
f
floatan element of the transformation matrix
asInline
booltrue 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
PdfImageXObjectthe
PdfImageXObject
objecta
floatan element of the transformation matrix
b
floatan element of the transformation matrix
c
floatan element of the transformation matrix
d
floatan element of the transformation matrix
e
floatan element of the transformation matrix
f
floatan element of the transformation matrix
AddXObject(PdfXObject)
Adds PdfXObject on canvas.
public virtual PdfCanvas AddXObject(PdfXObject xObject)
Parameters
xObject
PdfXObjectthe 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
PdfXObjectthe xObject to add
x
floatthe horizontal position of the xObject
y
floatthe 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
PdfXObjectthe xObject to add
rect
Rectanglethe 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
PdfXObjectthe xObject to add
a
floatan element of the transformation matrix
b
floatan element of the transformation matrix
c
floatan element of the transformation matrix
d
floatan element of the transformation matrix
e
floatan element of the transformation matrix
f
floatan 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
doublea corner of the enclosing rectangle.
y1
doublea corner of the enclosing rectangle.
x2
doublea corner of the enclosing rectangle.
y2
doublea corner of the enclosing rectangle.
startAng
doublestarting angle in degrees.
extent
doubleangle 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
doublea corner of the enclosing rectangle
y1
doublea corner of the enclosing rectangle
x2
doublea corner of the enclosing rectangle
y2
doublea corner of the enclosing rectangle
startAng
doublestarting angle in degrees
extent
doubleangle 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
PdfStreama 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
IPdfOCGThe 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()
.
BeginMarkedContent(PdfName)
Manually start a Marked Content sequence.
public virtual PdfCanvas BeginMarkedContent(PdfName tag)
Parameters
tag
PdfNamethe 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
PdfNamethe type of content that will be contained
properties
PdfDictionarythe 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
doublea corner of the enclosing rectangle.
y1
doublea corner of the enclosing rectangle.
x2
doublea corner of the enclosing rectangle.
y2
doublea corner of the enclosing rectangle.
startAng
doublestarting angle in degrees.
extent
doubleangle extent in degrees.
Returns
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
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
doubleoperand 1,1 in the matrix.
b
doubleoperand 1,2 in the matrix.
c
doubleoperand 2,1 in the matrix.
d
doubleoperand 2,2 in the matrix.
e
doubleoperand 3,1 in the matrix.
f
doubleoperand 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
AffineTransformaffine 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
PdfArrayaffine 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
doublex coordinate of the first control point.
y1
doubley coordinate of the first control point.
x3
doublex coordinate of the ending point.
y3
doubley 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
doublex coordinate of the second control point.
y2
doubley coordinate of the second control point.
x3
doublex coordinate of the ending point.
y3
doubley coordinate of the ending point.
Returns
- PdfCanvas
current canvas.
CurveTo(double, double, double, double, double, double)
Appends a Bê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
doublex coordinate of the first control point.
y1
doubley coordinate of the first control point.
x2
doublex coordinate of the second control point.
y2
doubley coordinate of the second control point.
x3
doublex coordinate of the ending point.
y3
doubley 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
doublea corner of the enclosing rectangle
y1
doublea corner of the enclosing rectangle
x2
doublea corner of the enclosing rectangle
y2
doublea 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
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
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
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
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
Returns
- PdfCanvas
current canvas.
NewlineShowText(string)
Moves to the next line and shows
text
.
public virtual PdfCanvas NewlineShowText(string text)
Parameters
text
stringthe 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
CanvasTagthe 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
TagReferencereference 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
PdfShadinga 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
doublex coordinate of the starting point.
y
doubley coordinate of the starting point.
width
doublewidth.
height
doubleheight.
Returns
- PdfCanvas
current canvas.
Rectangle(Rectangle)
Draws a rectangle.
public virtual PdfCanvas Rectangle(Rectangle rectangle)
Parameters
rectangle
Rectanglea 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
doublex coordinate of the starting point.
y
doubley coordinate of the starting point.
width
doublewidth.
height
doubleheight.
radius
doubleradius 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
floata parameter
Returns
- PdfCanvas
current canvas.
SetColor(Color, bool)
Changes the current color for paths.
public virtual PdfCanvas SetColor(Color color, bool fill)
Parameters
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
PdfColorSpacethe 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
boolset 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
PdfColorSpacethe 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
PdfPatterna pattern for the colored line or area
fill
boolset 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
SetExtGState(PdfExtGState)
Sets the ExtGState dictionary for the current graphics state
public virtual PdfCanvas SetExtGState(PdfExtGState extGState)
Parameters
extGState
PdfExtGStatea 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
PdfDictionarya 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
Colorfill 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
floata cyan value in the range [0,1]
m
floata magenta value in the range [0,1]
y
floata yellow value in the range [0,1]
k
floata 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
floata 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
floata red value in the range [0,1]
g
floata green value in the range [0,1]
b
floata 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.Shadingthe shading
Returns
- PdfCanvas
current canvas.
SetFlatnessTolerance(float)
Changes the Flatness.
public virtual PdfCanvas SetFlatnessTolerance(float flatnessTolerance)
Parameters
flatnessTolerance
floata 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
Returns
- PdfCanvas
The edited canvas.
SetHorizontalScaling(float)
Sets the horizontal scaling parameter.
public virtual PdfCanvas SetHorizontalScaling(float scale)
Parameters
scale
floata parameter.
Returns
- PdfCanvas
current canvas.
SetLeading(float)
Sets the text leading parameter.
public virtual PdfCanvas SetLeading(float leading)
Parameters
leading
floatthe 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
inta 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
floatthe 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
floatthe number of units that must be 'on' (equals the number of units that must be 'off').
phase
floatthe 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
floatthe number of units that must be 'on'
unitsOff
floatthe number of units that must be 'off'
phase
floatthe 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
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
inta line join style to be set
Returns
- PdfCanvas
current canvas.
SetLineWidth(float)
Sets line width.
public virtual PdfCanvas SetLineWidth(float lineWidth)
Parameters
lineWidth
floatline 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
floata miter limit to be set
Returns
- PdfCanvas
current canvas.
SetRenderingIntent(PdfName)
Set the rendering intent.
public virtual PdfCanvas SetRenderingIntent(PdfName renderingIntent)
Parameters
renderingIntent
PdfNamea 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
Colorstroke 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
floata cyan value in the range [0,1]
m
floata magenta value in the range [0,1]
y
floata yellow value in the range [0,1]
k
floata 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
floata 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
floata red value in the range [0,1]
g
floata green value in the range [0,1]
b
floata 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.Shadingthe shading
Returns
- PdfCanvas
current canvas.
SetTextMatrix(float, float)
Changes the text matrix.
public virtual PdfCanvas SetTextMatrix(float x, float y)
Parameters
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
floatoperand 1,1 in the matrix.
b
floatoperand 1,2 in the matrix.
c
floatoperand 2,1 in the matrix.
d
floatoperand 2,2 in the matrix.
x
floatoperand 3,1 in the matrix.
y
floatoperand 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
AffineTransformnew 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
inttext rendering mode @see PdfCanvasConstants.
Returns
- PdfCanvas
current canvas.
SetTextRise(float)
Sets the text rise parameter.
public virtual PdfCanvas SetTextRise(float textRise)
Parameters
textRise
floata 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
floata parameter
Returns
- PdfCanvas
current canvas.
ShowText(string)
Shows text (operator Tj).
public virtual PdfCanvas ShowText(string text)
Parameters
text
stringtext to show.
Returns
- PdfCanvas
current canvas.
ShowText(GlyphLine)
Shows text (operator Tj).
public virtual PdfCanvas ShowText(GlyphLine text)
Parameters
text
GlyphLinetext 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
GlyphLinetext 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
PdfArraythe 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
charthe
char
Returns
- PdfCanvas
current canvas.
WriteLiteral(float)
Outputs a
float
directly to the content.
public virtual PdfCanvas WriteLiteral(float n)
Parameters
n
floatthe
float
Returns
- PdfCanvas
current canvas.
WriteLiteral(string)
Outputs a
String
directly to the content.
public virtual PdfCanvas WriteLiteral(string s)
Parameters
s
stringthe
String
Returns
- PdfCanvas
current canvas.