5.20232.939
wijmo.pdf Class PdfPageArea Wijmo API Class

PdfPageArea Class

Represents an area of a page with its own coordinate system, where (0, 0) points to the top-left corner. Provides methods for drawing text, images, paths and transformations.

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

Heirarchy

Constructors

constructor

Properties

document

document: PdfDocument

Gets the document object.

height

height: number

Gets the height of the area, in points.

lineGap

lineGap: number

Gets or sets the spacing between each line of text, in points.

The default value is 0.

paths

paths: PdfPaths

Gets an object that provides ability to draw paths.

width

width: number

Gets the width of the area, in points.

x

x: number

Gets or sets the X-coordinate (in points) of the current point in the text flow used to draw a text or an image.

y

y: number

Gets or sets the Y-coordinate (in points) of the current point in the text flow used to draw a text or an image.

Methods

artifact

  • Marks content as an artifact.

    For example:

    doc.artifact(() => doc.drawText('Artifact'));
    

    Parameters

    Returns PdfPageArea

    The IPdfTagContent object that repesents a reference to the marked content.

beginArtifact

  • Begins marking content as an PDF artifact. Each call of beginArtifact() should be enclosed with endArtifact.

    For example:

    doc.beginArtifact();
    doc.drawText('Artifact');
    doc.endArtifact();
    

    Parameters

    Returns PdfPageArea

    The PdfPageArea object.

beginTagContent

  • Begins marking the content with the given tag and returns the tag content element, an object which represent a reference to the marked content. The tag content element can be incorporated into the document's structure tree by adding to a tag element. Each call of beginTagContent() should be enclosed with endTagContent.

    For example:

    let content = doc.beginTagContent(wijmo.pdf.PdfTagType.P);
    doc.drawText('Hello, world!');
    doc.endTagContent();
    
    let tag = doc.tag(wijmo.pdf.PdfTagType.P);
    tag.add(content);
    doc.addTag(tag);
    

    Note: Marking tag content will automatically end current marking of tag content (and any descendent marking).

    Parameters

    Returns IPdfTagContent

    The IPdfTagContent object that repesents a reference to the marked content.

drawImage

  • Draws an image in JPG or PNG format with the given options.

    If x and y are not defined, then x and y are used instead.

    Finally, if the image was drawn in the text flow, the method updates y. Hence, any subsequent text or image starts below this point.

    Parameters

    • src: string | IPdfImage

      A string containing the URL to get the image from, or the data URI containing a base64 encoded image, or a wijmo.pdf.IPdfImage object returned by the openImage method.

    • Optional x: number

      The x-coordinate of the point to draw the image at, in points.

    • Optional y: number

      The y-coordinate of the point to draw the image at, in points.

    • Optional options: IPdfImageDrawSettings

      Determines the image drawing options.

    Returns PdfPageArea

    The PdfPageArea object.

drawSvg

  • Draws a SVG image with the given options.

    If x and y are not defined, then x and y are used instead.

    The method uses the values of the width and height attributes of the outermost svg element to determine the scale factor according to the options.width and options.height properties. If any of these attributes are omitted then scaling is not performed and the image will be rendered in its original size.

    Finally, if the image was drawn in the text flow, the method updates y. Hence, any subsequent text or image starts below this point. The increment value is defined by the options.height property or by the outermost svg element's height attribute, which comes first. If none of them is provided then y will stay unchanged.

    The method supports a limited set of SVG features and provided primarily for rendering wijmo 5 chart controls.

    Parameters

    • url: string

      A string containing the URL to get the SVG image from or the data URI containing a base64 encoded SVG image.

    • Optional x: number

      The x-coordinate of the point to draw the image at, in points.

    • Optional y: number

      The y-coordinate of the point to draw the image at, in points.

    • Optional options: IPdfSvgDrawSettings

      Determines the SVG image drawing options.

    Returns PdfPageArea

    The PdfPageArea object.

drawText

  • Draws a string with the given options and returns the measurement information.

    If options.pen, options.brush or options.font are omitted, the current document's pen, brush or font are used (see PdfDocument.setPen, PdfDocument.setBrush, and PdfDocument.setFont).

    The string is drawn within the rectangular area for which top-left corner, width and height are defined by the x, y, options.width and options.height values. If x and y are not provided, the PdfDocument.x and PdfDocument.y properties are used instead.

    The text is wrapped and clipped automatically within the area. If options.height is not provided and the text exceeds the bottom body edge, then a new page will be added to accommodate the text.

    Finally, the method updates the value of the PdfDocument.x and PdfDocument.y properties. Hence, any subsequent text or image starts below this point (depending on the value of options.continued).

    The measurement result doesn't reflect the fact that text can be split into multiple pages or columns; the text is treated as a single block.

    Parameters

    • text: string

      The text to draw.

    • Optional x: number

      The X-coordinate of the point to draw the text at, in points.

    • Optional y: number

      The Y-coordinate of the point to draw the text at, in points.

    • Optional options: IPdfTextDrawSettings

      Determines the text drawing options.

    Returns IPdfTextMeasurementInfo

    A IPdfTextMeasurementInfo object determines the measurement information.

endArtifact

  • Ends marking content as an PDF artifact.

    For example:

    doc.beginArtifact();
    doc.drawText('Artifact');
    doc.endArtifact();
    

    Returns PdfPageArea

    The PdfPageArea object.

endTagContent

  • Ends the tag content marking.

    For example:

    let content = doc.beginTagContent(wijmo.pdf.PdfTagType.P);
    doc.drawText('Hello, world!');
    doc.endTagContent();
    

    Returns PdfPageArea

    The PdfPageArea object.

lineHeight

  • lineHeight(font?: PdfFont): number
  • Gets the line height with a given font.

    If font is not specified, then font used in the current document is used.

    Parameters

    • Optional font: PdfFont

      Font to get the line height.

    Returns number

    The line height, in points.

measureText

  • Measures a text with the given font and text drawing options without rendering it.

    If font is not specified, then the font used in the current document is used.

    The method uses the same text rendering engine as drawText, so it is tied up in the same way to x and the right page margin, if options.width is not provided. The measurement result doesn't reflect the fact that text can be split into multiple pages or columns; the text is treated as a single block.

    Parameters

    Returns IPdfTextMeasurementInfo

    A IPdfTextMeasurementInfo object determines the measurement information.

moveDown

  • Moves down the y by a given number of lines using the given font or, using the font of current document, if not specified.

    Parameters

    • Optional lines: number

      Number of lines to move down.

    • Optional font: PdfFont

      Font to calculate the line height.

    Returns PdfPageArea

    The PdfPageArea object.

moveUp

  • Moves up the y by a given number of lines using the given font or, using the font of current document, if not specified.

    Parameters

    • Optional lines: number

      Number of lines to move up.

    • Optional font: PdfFont

      Font to calculate the line height.

    Returns PdfPageArea

    The PdfPageArea object.

openImage

  • Opens an image in JPG or PNG format.

    Parameters

    • url: string

      A string containing the URL to get the image from or the data URI containing a base64 encoded image.

    Returns IPdfImage

    The IPdfImage object containing image data.

rotate

  • Rotates the graphic context clockwise by a specified angle.

    Parameters

    • angle: number

      The rotation angle, in degrees.

    • Optional origin: Point

      The Point of rotation, in points. If it is not provided, then the top left corner is used.

    Returns PdfPageArea

scale

  • Scales the graphic context by a specified scaling factor.

    The scaling factor value within the range [0, 1] indicates that the size will be decreased. The scaling factor value greater than 1 indicates that the size will be increased.

    Parameters

    • xFactor: number

      The factor to scale the X dimension.

    • Optional yFactor: number

      The factor to scale the Y dimension. If it is not provided, it is assumed to be equal to xFactor.

    • Optional origin: Point

      The Point to scale around, in points. If it is not provided, then the top left corner is used.

    Returns PdfPageArea

    The PdfPageArea object.

tagContent

  • Marks content with the given tag and returns the tag content element, an object which represent a reference to the marked content. The tag content element can be incorporated into the document's structure tree by adding to a tag element.

    For example:

    let content = doc.tagContent(wijmo.pdf.PdfTagType.P, () => doc.drawText('Hello, world!'));
    
    let tag = doc.tag(wijmo.pdf.PdfTagType.P);
    tag.add(content);
    doc.addTag(tag);
    

    Parameters

    Returns IPdfTagContent

    The IPdfTagContent object that repesents a reference to the marked content.

transform

  • transform(a: number, b: number, c: number, d: number, e: number, f: number): PdfPageArea
  • Transforms the graphic context with given six numbers which represents a 3x3 transformation matrix.

    A transformation matrix is written as follows:

    ab0
    cd0
    ef1

    Parameters

    • a: number

      Value of the first row and first column.

    • b: number

      Value of the first row and second column.

    • c: number

      Value of the second row and first column.

    • d: number

      Value of the second row and second column.

    • e: number

      Value of the third row and first column.

    • f: number

      Value of the third row and second column.

    Returns PdfPageArea

    The PdfPageArea object.

translate

  • Translates the graphic context with a given distance.

    Parameters

    • x: number

      The distance to translate along the X-axis, in points.

    • y: number

      The distance to translate along the Y-axis, in points.

    Returns PdfPageArea

    The PdfPageArea object.