v5.20192.631
|

PdfPaths Class

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

Path creation method calls must be finished with the PdfPaths.stroke, PdfPaths.fill, PdfPaths.fillAndStroke or PdfPaths.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 PdfPaths.lineTo, PdfPaths.bezierCurveTo and PdfPaths.quadraticCurveTo methods should not start the path, they must be preceded with the PdfPaths.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.

Hierarchy

  • PdfPaths

Constructors

constructor

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

    • cp1x: number

      The X-coordinate of the first control point, in points.

    • cp1y: number

      The Y-coordinate of the first control point, in points.

    • cp2x: number

      The X-coordinate of the second control point, in points.

    • cp2y: number

      The Y-coordinate of the second control point, in points.

    • x: number

      The X-coordinate of the new point, in points.

    • y: number

      The Y-coordinate of the new point, in points.

    Returns PdfPaths

    The PdfPaths object.

circle

  • circle(x: number, y: number, radius: number): PdfPaths
  • Draws a circle.

    Parameters

    • x: number

      The X-coordinate of the center of the circle, in points.

    • y: number

      The Y-coordinate of the center of the circle, in points.

    • radius: number

      The radius of the circle, in points.

    Returns PdfPaths

    The PdfPaths object.

clip

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

    Parameters

    Returns PdfPaths

    The PdfPaths object.

closePath

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

    Returns PdfPaths

    The PdfPaths object.

ellipse

  • ellipse(x: number, y: number, radiusX: number, radiusY?: number): PdfPaths
  • Draws an ellipse.

    Parameters

    • x: number

      The X-coordinate of the center of the ellipse, in points.

    • y: number

      The Y-coordinate of the center of the ellipse, in points.

    • radiusX: number

      The radius of the ellipse along the X-axis, in points.

    • Optional radiusY: number

      The radius of the ellipse along the Y-axis, in points. If it is not provided, then it is assumed to be equal to radiusX.

    Returns PdfPaths

    The PdfPaths object.

fill

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

    The brushOrColor argument can accept the following values:

    Parameters

    • Optional brushOrColor: any

      The brush or color to use.

    • Optional rule: PdfFillRule

      The fill rule to use.

    Returns PdfPaths

    The PdfPaths object.

fillAndStroke

  • 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 PdfDocument.setBrush, PdfDocument.setPen methods).

    The brushOrColor argument can accept the following values:

    The penOrColor argument can accept the following values:

    Parameters

    • Optional brushOrColor: any

      The brush or color to use.

    • Optional penOrColor: any

      The pen or color to use.

    • Optional rule: PdfFillRule

      The fill rule to use.

    Returns PdfPaths

    The PdfPaths object.

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

    • x: number

      The X-coordinate of the new point, in points.

    • y: number

      The Y-coordinate of the new point, in points.

    Returns PdfPaths

    The PdfPaths object.

moveTo

  • moveTo(x: number, y: number): PdfPaths
  • Sets a new current point.

    Parameters

    • x: number

      The X-coordinate of the new point, in points.

    • y: number

      The Y-coordinate of the new point, in points.

    Returns PdfPaths

    The PdfPaths object.

polygon

  • Draws a polygon using a given points array.

    Parameters

    • points: number[][]

      An array of two-elements arrays [x, y] specifying the X and Y coordinates of the point, in points.

    Returns PdfPaths

    The PdfPaths object.

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

    • cpx: number

      The X-coordinate of the control point, in points.

    • cpy: number

      The Y-coordinate of the control point, in points.

    • x: number

      The X-coordinate of the new point, in points.

    • y: number

      The Y-coordinate of the new point, in points.

    Returns PdfPaths

    The PdfPaths object.

rect

  • rect(x: number, y: number, width: number, height: number): PdfPaths
  • Draws a rectangle.

    Parameters

    • x: number

      The X-coordinate of the topleft corner of the rectangle, in points.

    • y: number

      The Y-coordinate of the topleft corner of the rectangle, in points.

    • width: number

      The width of the rectangle, in points.

    • height: number

      The width of the rectangle, in points.

    Returns PdfPaths

    The PdfPaths object.

roundedRect

  • roundedRect(x: number, y: number, width: number, height: number, cornerRadius?: number): PdfPaths
  • Draws a rounded rectangle.

    Parameters

    • x: number

      The X-coordinate of the upper-left corner of the rectangle, in points.

    • y: number

      The Y-coordinate of the upper-left corner of the rectangle, in points.

    • width: number

      The width of the rectangle, in points.

    • height: number

      The width of the rectangle, in points.

    • Optional cornerRadius: number

      The corner radius of the rectangle, in points. The default value is 0.

    Returns PdfPaths

    The PdfPaths object.

stroke

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

    The penOrColor argument can accept the following values:

    Parameters

    • Optional penOrColor: any

      The pen or color to use.

    Returns PdfPaths

    The PdfPaths object.

svgPath

  • Draws a SVG 1.1 path.

    Parameters

    • path: string

      The SVG path to draw.

    Returns PdfPaths

    The PdfPaths object.