Persits Software, Inc. Web Site
 Navigator:  Home |  Object Reference |  PdfCanvas
PdfCell PdfAnnots
  PdfCanvas Object
PdfCanvas encapsulates AspPDF.NET's drawing functionality. PdfCanvas is returned by PdfPage's Canvas and Background properties, as well as by PdfGraphics' Canvas property. For more information about drawing, see Chapter 4: Drawing.

Properties Methods
HtmlTag
LineCap
LineJoin
LineWidth
MiterLimit
Value
AbandonPath
AddCurve
AddEllipse
AddRect
Append
BeginMarkedContent
BeginText
Clear
Clip
ClosePath
DrawBarcode
DrawBarcode2D
DrawEllipse
DrawGraphics
DrawImage
DrawLine
DrawRect
DrawTable
DrawText
EndMarkedContent
EndText
Fill
FillEllipse
FillRect
FillStroke
FillWithPattern
FillWithShading
LineTo
MoveTo
RestoreState
SaveState
SetColor
SetColorCMYK
SetColorEx
SetColorSpace
SetCTM
SetFillColor
SetFillColorCMYK
SetFillColorEx
SetFillColorSpace
SetGState
SetParams
SetTM
Stroke

Properties


string HtmlTag (Read-only)

Returns an HTML tag reflecting the current font state when using AspPDF.NET's HTML support. This property is populated by a call to the DrawText method with the HTML parameter set to True and a text string too long to fit in the allocated space. Use it to correctly display HTML text spanning multiple pages. For more information, see Section 6.4 - HTML Support.

int LineCap (Read/Write)

Returns or specifies the current line cap style. Valid values are 0 (Butt cap), 1 (Round cap) and 2 (Projecting square cap) described in Section 4.4.2 - Line Width and Cap Style.

int LineJoin (Read/Write)

Returns or specifies the current line join style. Valid values are 0 (Miter join), 1 (Round join) and 2 (Bevel join) described in Section 4.4.3 - Line Join Style and Miter Limit.

float LineWidth (Read/Write)

Returns or specifies the current line width. Line width is 1 by default (in user units).

For more information, see Section 4.4.2 - Line Width and Cap Style.


float MiterLimit (Read/Write)

Returns or specifies the current miter limit described in Section 4.4.3 - Line Join Style and Miter Limit.

string Value (Read-only)

Returns the current canvas contents as a sequence of operators in a language similar to PostScript. This property is only useful for trouble-shooting or debugging purposes.

Methods

void AbandonPath ( )
This method cancels all previous path-construction operators. For more information on path construction, see Section 4.1 - Introduction to PDF Drawing

void AddCurve ( float X1, float Y1, float X2, float Y2, float X3, float Y3 )
Adds a Bezier curve to the current path using the current point as the beginning, point (X3, Y3) as the ending, and points (X1, Y1) and (X2, Y2) as control points. For more information on paths and Bezier curves, see Section 4.1 - Introduction to PDF Drawing.

void AddEllipse ( float X, float Y, float RX, float RY )
Adds an ellipse to the current path with the center in (X, Y) and radii RX and RY. If RX=RY, the ellipse turns into a circle.

void AddRect ( float X, float Y, float Width, float Height )
Adds a rectangle to the current path with the lower-left corner in (X, Y) and size Width x Height.

void Append ( string Contents )
Appends raw PostScript operators directly to the content stream of the canvas. This method should only be used by developers with advanced PDF knowledge.

int BeginMarkedContent ( )
Begins a marked content sequence of drawing operators. Returns the unique ID for this marked content. Must be matched with a call to EndMarkedContent.

For more information, see Section 14.3.4 - PDF/A-3 Compliance.

This method was introduced in Version 3.7.


void BeginText ( )
Appends the PDF language operator BT to the content stream of the canvas. This method should only be used by developers with advanced PDF knowledge.

void Clear ( )
Clears the current canvas of all drawing operators.

void Clip ( )
void Clip ( bool EvenOdd )
Adds the current path to the clipping path. For more information on clipping paths, see Section 4.5.3 - Clipping Paths.

EvenOdd specifies the filling rule to be used. If set to True or omitted, the nonzero winding number rule is used, otherwise the even-odd rule is used. For more information on filling rules Section 4.2 - AspPDF Implementation of Drawing.


void ClosePath ( )
Closes the current subpath by appending a straight line from the current point to the beginning of the subpath.

void DrawBarcode ( string Data, object Param )
Draws a scanable bar code on the canvas.

Data specifies the data (digits and letters) to be displayed as a barcode.

Param is a parameter object or parameter string specifying the barcode type as well as other parameters.

For the full description of the DrawBarcode method and its parameters, see Section 13.1 - Regular Barcodes.


PdfParam DrawBarcode2D ( string TextData, object Param )
PdfParam DrawBarcode2D ( byte [ ] BinaryData, object Param )
Draws a two-dimensional barcode on a page. Currently, four types are supported: PDF417, Data Matrix, QR Code and Aztec. Returns various properties of the barcode symbol just drawn.

TextData specifies the data to be encoded as a barcode.

BinaryData specifies binary information to be encoded as a barcode.

Param is a PdfParam object or parameter string specifying the following barcode properties:

The method returns an instance of the PdfParam object populated with the following properties of the symbol just rendered: Width, Height, Columns, Rows and ErrorLevel (the latter is only returned when Type=1.)

For more information about 2D barcodes and the DrawBarcode2D method, see Section 13.2 - Two-Dimensional Barcodes.


void DrawEllipse ( float X, float Y, float RX, float RY )
Draws an ellipse with the center in (X, Y) and radii RX and RY. If RX = RY, the ellipse turns into a circle.

void DrawGraphics ( PdfGraphics Graphics, object Param )
Draws a PdfGraphics object on the canvas.

Graphics is an instance of the PdfGraphics object representing the graphics object to be drawn.

Param is a PdfParam object or parameter string specifying the following drawing parameters:

  • X, Y (required): the coordinates of the lower-left corner of the graphics on the canvas.
  • Angle (optional): the angle (in degrees) to rotate the graphics counter-clockwise around its lower-left corner.
  • ScaleX, ScaleY (optional): the scaling factors along the X and Y axes, respectively.
Usage:

objPage.Canvas.DrawGraphics( objGraphics, "x=10; y=300" );

For more information on the PdfGraphics object, see Section 5.3 - PdfGraphics Object.


void DrawImage ( PdfImage Image, object Param )
Draws a PdfImage object on the canvas.

Image is an instance of the PdfImage object representing the image to be drawn.

Param is a PdfParam object or parameter string specifying image drawing parameters. The parameters are the same as in the DrawGraphics method.

Usage:

objPage.Canvas.DrawImage( objImage, "x=10;y=300,ScaleX=.5,Scaley=.5" );

For more information on the PdfImage object, see Section 5.1 - PdfImage Object.


void DrawLine ( float X1, float Y1, float X2, float Y2 )
Draws a line from point (X1, Y1) to point (X2, Y2).

void DrawRect ( float X, float Y, float Width, float Height )
Draws a rectangle with the lower-left corner in (X, Y) and size Width x Height.

int DrawTable ( PdfTable Table, object Param )
Draws a table, or a portion thereof, on the canvas.

Table is an instance of the PdfTable object creatable via PdfDocument's CreateTable method. Only rows that fully fit on the canvas are displayed. When the next row cannot be fit on the canvas, the process stops.

Param is a PdfParam object or parameter string specifying the following table drawing parameters:

  • X, Y (required): the coordinates of the upper-left corner of the table on the canvas.
  • MaxHeight (optional): the maximum height of the table on the canvas. By default, it is set to the Y value (the distance between the top of the table and bottom of the canvas).
  • RowFrom - RowTo, RowFrom1 - RowTo1, etc. (optional) - row ranges to display.

The method returns the index of the last row it could fully fit on the canvas. If the method returns 0 it means even the first row alone could not fit and nothing was drawn.

Usage:

objPage.Canvas.DrawTable( Table, "x=10; y=200; RowFrom=1; RowTo=20" );

For more information on the PdfTable object, see Chapter 7 - Tables. For the full description of the DrawTable method, see Section 7.3 - Table Rendering.


int DrawText ( string Text, object Param, PdfFont Font )
Draws a text string specified by Text using the font specified by Font.

Param is a PdfParam object or parameter string specifying the following text drawing parameters.

The method returns the number of printed characters. This number may be less than the length of the original text string if the entire string did not fit in the provided bounding box.

Usage:

objPage.Canvas.DrawText( "Hello World!", "x=10; y=200", Font );

For more information on text and fonts, see Chapter 6 - Text and Fonts. For the full description of the DrawText method, see Section 6.1 - Bounding Box Parameters.


void EndMarkedContent ( )
Ends a marked content sequence of drawing operators begun by a call to BeginMarkedContent.

For more information, see Section 14.3.4 - PDF/A-3 Compliance.

This method was introduced in Version 3.7.


void EndText ( )
Appends the PDF language operator ET to the content stream of the canvas. This method should only be used by developers with advanced PDF knowledge.

void Fill ( )
void Fill ( bool EvenOdd )
Fills the current path. EvenOdd specifies the filling rule to be used. If set to True or omitted, the nonzero winding number rule is used, otherwise the even-odd rule is used. For more information on filling rules Section 4.2 - AspPDF.NET Implementation of Drawing.

void FillEllipse ( float X, float Y, float RX, float RY )
Fills an ellipse with the center in (X, Y) and radii RX and RY. If RX = RY, the ellipse turns into a circle.

void FillRect ( float X, float Y, float Width, float Height )
Fills a rectangle with the lower-left corner in (X, Y) and size Width x Height.

void FillStroke ( )
void FillStroke ( bool EvenOdd )
Fills, then strokes the current path. EvenOdd specifies the filling rule to be used. If set to True or omitted, the nonzero winding number rule is used, otherwise the even-odd rule is used. For more information on filling rules Section 4.2 - AspPDF.NET Implementation of Drawing.

void FillWithPattern ( PdfGraphics Graph )
void FillWithPattern ( PdfGraphics Graph, bool EvenOdd )
Fills the current path with a pattern cell specified by Graph, a PdfGraphics object created using the Pattern=true parameter. EvenOdd specifies the filling rule to be used (see Fill for the description of this argument).

For more information about patterns, see Section 5.3.2 - Tiling Patterns.

This method was introduced by version 1.6.


void FillWithShading (PdfShading Shading)
Fills the current path with a shading specified by Shading, a PdfShading object creatable via the PdfDocument.CreateShading method.

For more information, see Section 16.5 - Patterns and Shadings.

This method was introduced by version 3.5.


void LineTo ( float X, float Y )
Appends a straight line segment to the current path extending from the current point to (X, Y).

void MoveTo ( float X, float Y )
Starts a new subpath from the point (X, Y).

void RestoreState ( )
Restores the graphics state saved with SaveState. For more information about saving and restoring the graphics state, Section 4.5.2 - Graphics State Stack.

void SaveState ( )
Saves the current graphics state. For more information about saving and restoring the graphics state, Section 4.5.2 - Graphics State Stack.

void SetColor ( float R, float G, float B )
Sets the current color in RGB color space to be used by all stroking methods such as Stroke, DrawLine, DrawRect, DrawEllipse, etc. The current color is black by default.

R, G, B specify the RGB components of the color in the range [0, 1].


void SetColorCMYK ( float C, float M, float Y, float K )
Sets the current color in CMYK color space to be used by all stroking methods such as Stroke, DrawLine, DrawRect, DrawEllipse, etc. The current color is black by default.

C, M, Y, K specify the CMYK components of the color in the range [0, 1].


void SetColorEx ( object Param )
Sets the current stroking color. Does not change the current color space. An arbitrary number of color components can be specified. This method should be used in conjunction with the SetColorSpace method.

Param is a PdfParam object or parameter string specifying the color component values:

  • c1, c2, ..., cN (required) - color components in the range [0.0, 1.0]. The number of color components must match the currently selected color space.

As of Version 3.5, Param can also be an instance of the PdfGraphics object representing a pattern to be used as the current stroking color.

Usage:

' Set current stroking color via its color components
objPage.Canvas.SetColorSpace( objDoc.CreateColorSpace("DeviceRGB") );
objPage.Canvas.SetColorEx( "c1=0.5; c2=0.3; c3=1" );
// 3 color components

' Set a pattern as current stroking color
PdfGraphics objPattern = objDoc.CreatePattern(...);
objPage.Canvas.SetColorEx( objPattern );
// use pattern as current color

For more information, see Section 16.1 - Color Spaces, Section 16.5 - Patterns and Shadings.

This method was introduced by Version 2.5.


void SetColorSpace ( PdfColorSpace ColorSpace )

Sets the current stroking color space to ColorSpace.

For more information, see Section 16.1 - Color Spaces.

This method was introduced by Version 2.5.


void SetCTM ( float a, float b, float c, float d, float e, float f )
Sets the current transformation matrix (CTM). For more information about the transformation matrix, see Section 4.5.1 - Transformation Martix.

void SetFillColor ( float R, float G, float B )
Sets the current fill color in RGB color space to be used by all filling methods such as Fill, FillStroke, FillRect, FillEllipse, etc. The current fill color is black by default.

R, G, B specify the RGB components of the color in the range [0, 1].


void SetFillColorCMYK ( float C, float M, float Y, float K )
Sets the current fill color in CMYK color space to be used by all filling methods such as Fill, FillStroke, FillRect, FillEllipse, etc. The current fill color is black by default.

C, M, Y, K specify the CMYK components of the color in the range [0, 1].


void SetFillColorEx ( object Param )
Sets the current fill color. Does not change the current color space. An arbitrary number of color components can be specified. This method should be used in conjunction with the SetFillColorSpace method.

Param is a PdfParam object or parameter string specifying the color component values:

  • c1, c2, ..., cN (required) - color components in the range [0.0, 1.0]. The number of color components must match the currently selected color space.

As of Version 3.5, Param can also be an instance of the PdfGraphics object representing a pattern to be used as the current fill color.

Usage:

' Set current fill color via its color components
objPage.Canvas.SetColorSpace( objDoc.CreateColorSpace("DeviceRGB") );
objPage.Canvas.SetFillColorEx( "c1=0.5; c2=0.3; c3=1" );
// 3 color components

' Set a pattern as current fill color
PdfGraphics objPattern = objDoc.CreatePattern(...);
objPage.Canvas.SetFillColorEx( objPattern );
// use pattern as current color

For more information, see Section 16.1 - Color Spaces, Section 16.5 - Patterns and Shadings.

This method was introduced by Version 2.5.


void SetFillColorSpace ( PdfColorSpace ColorSpace )

Sets the current fill color space to ColorSpace.

For more information, see Section 16.1 - Color Spaces.

This method was introduced by Version 2.5.


void SetGState ( PdfGState GState )

Sets the current graphics state object to GState.

For more information, see Section 19.1 - PdfGState: Overview.

This method was introduced by Version 3.1.


void SetParams ( object Param )
Enables setting several graphics state parameters at once via a PdfParam object or parameter string. These parameters include: Usage:

Canvas.SetParams( "Color=blue; FillColor=yellow; LineWidth=3" );
Canvas.SetParams( "Color=&H0000FF; FillColor=&HFFFF00; Dash1=2" );
Canvas.SetParams( "r=1; g=0; b=.5;" );


void SetTM ( float a, float b, float c, float d, float e, float f )
Sets the current text transformation matrix (TM). A TM is similar to CTM except that it applies to text operators only. This method should be used by advanced users only.

void Stroke ( )
Strokes the current path.

PdfCell PdfAnnots
Search AspPDF.net

Newsletter Signup

Other Products
AspPDF
AspUpload
AspJpeg
AspEmail
AspEncrypt
AspGrid
AspUser
  This site is owned and maintained by Persits Software, Inc. Copyright © 2003 - 2014. All Rights Reserved.