Click or drag to resize
Pdf Library for .NET

PdfCanvas Class

Base class for objects that can render pdf page elements.
Inheritance Hierarchy
SystemObject
  SelectPdf.UniversalPdfCanvas
    SelectPdf.UniversalPdfPage
    SelectPdf.UniversalPdfTemplate

Namespace: SelectPdf.Universal
Assembly: SelectPdf.Universal (in SelectPdf.Universal.dll) Version: 26.4
Syntax
public abstract class PdfCanvas

The PdfCanvas type exposes the following members.

Constructors
 NameDescription
Protected methodPdfCanvas 
Top
Properties
 NameDescription
Public propertyClientRectangle Gets the drawable area of the canvas. The page margins (and, for a page, the document header and footer) are excluded.
Top
Methods
 NameDescription
Public methodAdd Adds a pdf page element to the canvas.
Public methodCode exampleAddAsync(PdfPageElement) Adds a pdf page element to the canvas without waiting for it to be rendered.
Public methodAddAsync(PdfPageElement, CancellationToken) Adds a pdf page element to the canvas without waiting for it to be rendered, stopping when the specified token is cancelled.
Public methodMeasureString Measures the size of the specified string when rendered with the specified font.
Top
Remarks
PdfCanvas is the base class for PdfPage and PdfTemplate. Use PdfPage to add elements at a specific position on a single page; use PdfTemplate to add elements that repeat on more than one page.
Example
PdfDocument document = new PdfDocument();
PdfCanvas canvas = document.AddPage();
PdfFont font = PdfFont.CreateStandardFont(PdfStandardFont.Helvetica, 12f);
SizeF size = canvas.MeasureString("Hello", font);
RectangleF area = canvas.ClientRectangle;
document.Close();
See Also