PdfPaths Class

File
wijmo.pdf.js
Module
wijmo.pdf

Provides methods for creating graphics paths and drawing them or using them for clipping.

Path creation method calls must be finished with the stroke, fill, fillAndStroke or clip method. Any document methods which don't apply directly to path creation/ drawing/ clipping (changing a pen, drawing a text, saving the graphics state etc) are prohibited to use until the path is finished. The lineTo, bezierCurveTo and quadraticCurveTo methods should not start the path, they must be preceded with the moveTo.

The methods are chainable:

doc.paths.moveTo(0, 0).lineTo(100, 100).stroke();

This class is not intended to be instantiated in your code.

Constructor

Methods

Constructor

constructor

constructor(doc: PdfDocument, offset: Point): PdfPaths

Initializes a new instance of the PdfPaths class.

Parameters
Returns
PdfPaths

Methods

bezierCurveTo

bezierCurveTo(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, y: number): PdfPaths

Draws a bezier curve from the current point to a new point using the (cp1x, cp1y) and (cp2x, cp2y) as the control points.

The new current point is (x, y).

Parameters
Returns
PdfPaths

circle

circle(x: number, y: number, radius: number): PdfPaths

Draws a circle.

Parameters
Returns
PdfPaths

clip

clip(rule?: PdfFillRule): PdfPaths

Creates a clipping path used to limit the regions of the page affected by painting operators.

Parameters
Returns
PdfPaths

closePath

closePath(): PdfPaths

Closes the current path and draws a line from the current point to the initial point of the current path.

Returns
PdfPaths

ellipse

ellipse(x: number, y: number, radiusX: number, radiusY?: number): PdfPaths

Draws an ellipse.

Parameters
Returns
PdfPaths

fill

fill(brushOrColor?: any, rule?: PdfFillRule): PdfPaths

Fills the path with the specified brush and rule. If brush is not specified, then the default document brush will be used (see the setBrush method).

The brushOrColor argument can accept the following values:

  • A PdfBrush object.
  • A Color object or any string acceptable by the fromString method. In this case, the PdfBrush object with the specified color will be created internally.

Parameters
Returns
PdfPaths

fillAndStroke

fillAndStroke(brushOrColor?: any, penOrColor?: any, rule?: PdfFillRule): PdfPaths

Fills and strokes the path with the specified brush, pen and rule. If brush and pen is not specified, then the default document brush and pen will be used (See the setBrush, setPen methods).

The brushOrColor argument can accept the following values:

  • A PdfBrush object.
  • A Color object or any string acceptable by the fromString method. In this case, the PdfBrush object with the specified color will be created internally.

The penOrColor argument can accept the following values:

  • A PdfPen object.
  • A Color object or any string acceptable by the fromString method. In this case, the PdfPen object with the specified color will be created internally.

Parameters
Returns
PdfPaths

lineTo

lineTo(x: number, y: number): PdfPaths

Draws a line from the current point to a new point.

The new current point is (x, y).

Parameters
Returns
PdfPaths

moveTo

moveTo(x: number, y: number): PdfPaths

Sets a new current point.

Parameters
Returns
PdfPaths

polygon

polygon(points: number[][]): PdfPaths

Draws a polygon using a given points array.

Parameters
Returns
PdfPaths

quadraticCurveTo

quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): PdfPaths

Draws a quadratic curve from the current point to a new point using the current point and (cpx, cpy) as the control points.

The new current point is (x, y).

Parameters
Returns
PdfPaths

rect

rect(x: number, y: number, width: number, height: number): PdfPaths

Draws a rectangle.

Parameters
Returns
PdfPaths

roundedRect

roundedRect(x: number, y: number, width: number, height: number, cornerRadius?: number): PdfPaths

Draws a rounded rectangle.

Parameters
Returns
PdfPaths

stroke

stroke(penOrColor?: any): PdfPaths

Strokes the path with the specified pen. If pen is not specified, then the default document pen will be used (See the setPen method).

The penOrColor argument can accept the following values:

  • A PdfPen object.
  • A Color object or any string acceptable by the fromString method. In this case, the PdfPen object with the specified color will be created internally.

Parameters
Returns
PdfPaths

svgPath

svgPath(path: string): PdfPaths

Draws a SVG 1.1 path.

Parameters
Returns
PdfPaths