ComPDFKit Web SDK
    Preparing search index...

    Class SignatureCreateTool

    Base class for objects that fire named events. Listener arguments are passed by position.

    Hierarchy (View Summary)

    • Tool
      • SignatureCreateTool
    Index
    • get ALLOW_ANNOTS_OUTSIDE_PAGE(): boolean

      Whether annotations can be dragged outside the page (off by default: dragging stops at the page edge and does not move in a direction where the annotation is larger than the page).

      Returns boolean

    • set ALLOW_ANNOTS_OUTSIDE_PAGE(allow: boolean): void

      Whether annotations can be dragged outside the page (off by default: dragging stops at the page edge and does not move in a direction where the annotation is larger than the page).

      Parameters

      • allow: boolean

      Returns void

    • Adds a listener for an event. Adding the same function twice for one event has no effect.

      Type Parameters

      • K extends keyof ToolEvents

      Parameters

      • name: K

        Event name.

      • fn: (...args: ToolEvents[K]) => void

        Listener, called with the event arguments.

      • Optionaloptions: { once?: boolean }

        Listener options.

        • Optionalonce?: boolean

          When true, the listener is removed after it runs once.

      Returns void

    • Places the full signature: on the recorded signature field if any, at the recorded position if any, otherwise in the middle of the current page.

      Returns Promise<void>

    • Allows annotations to be dragged outside the page (sets ALLOW_ANNOTS_OUTSIDE_PAGE to true).

      Returns void

    • Clears the recorded position and signature field.

      Returns void

    • Clears the pad and the corresponding signature.

      Returns void

    • Called when the context menu is requested on the viewer; does nothing in the base class.

      Parameters

      • _e: MouseEvent

        The mouse event.

      Returns void

    • Deletes all saved signatures, firing signatureDeleted for each.

      Returns void

    • Deletes a saved signature and fires signatureDeleted.

      Parameters

      • index: number

        Zero-based index in the saved signatures.

      Returns void

    • Turns off hover cursors: the tool's own cursor is always used (sets ENABLE_ANNOTATION_HOVER_CURSORS to false).

      Returns void

    • Turns off automatic text selection by the edit tool (sets ENABLE_AUTO_SWITCH to false).

      Returns void

    • Keeps dragged annotations inside the page (sets ALLOW_ANNOTS_OUTSIDE_PAGE to false; the default).

      Returns void

    • Turns on hover cursors (sets ENABLE_ANNOTATION_HOVER_CURSORS to true).

      Returns void

    • Turns on automatic text selection by the edit tool (sets ENABLE_AUTO_SWITCH to true).

      Returns void

    • Exports saved signatures: strokes for hand-drawn ones (ink XFDF when pathsOnly is false), dataURLs for images.

      Parameters

      • OptionalpathsOnly: boolean

      Returns Promise<(string | Core.Annotations.Point[][] | undefined)[]>

    • Viewport event → the page and page coordinates under the pointer (unrotated page, top-left origin, pt).

      Parameters

      • e: Pick<MouseEvent, "clientX" | "clientY">

      Returns MouseLocation

    • Preview image of the signature (dataURL): hand-drawn signatures are drawn at the pad's height and the signature's width; image signatures are the image itself.

      Parameters

      Returns Promise<string>

    • Gets how signature fields are signed.

      Returns SigningModes

      The signing mode; ANNOTATION by default.

    • Whether a position (or signature field) for the next signature has been recorded.

      Returns boolean

      True when a location is recorded.

    • Stops the preview following the pointer and removes it; clicks then only record the position.

      Returns void

    • Reads back the result of exportSignatures (one item or an array; each strokes, an image dataURL or ink XFDF) into the saved signatures.

      Parameters

      • data: string | (string | { x: number; y: number }[][])[]
        • string
        • (string | { x: number; y: number }[][])[]
          • string
          • { x: number; y: number }[][]
            • x: number

              X in signature pad pixels.

            • y: number

              Y in signature pad pixels.

      Returns Promise<void>

    • Whether there is no usable signature: no signature, an ink signature without strokes, or an image signature without image, text or icon.

      Returns Promise<boolean>

      True when the signature is empty.

    • Called when a key is pressed while the viewer has focus; does nothing in the base class.

      Parameters

      • _e: KeyboardEvent

        The keyboard event.

      Returns void

    • Called on a double-click in the viewer; does nothing in the base class.

      Parameters

      • _e: MouseEvent

        The mouse event.

      Returns void

    • Called when the left mouse button or a touch goes down on the viewer; does nothing in the base class.

      Parameters

      • _e: PointerEvent

        The pointer event.

      Returns void

    • Places the previewed signature at the click; without one, records the position and fires locationSelected (the UI gets a signature, then calls addSignature).

      Parameters

      • e: PointerEvent

      Returns void

    • Called when the pointer moves over the viewer; does nothing in the base class.

      Parameters

      • e: PointerEvent

      Returns void

    • Called when the right mouse button goes down on the viewer; does nothing in the base class.

      Parameters

      • _e: PointerEvent

        The pointer event.

      Returns void

    • Removes a listener, or every listener of the event when fn is omitted.

      Type Parameters

      • K extends keyof ToolEvents

      Parameters

      • name: K

        Event name.

      • Optionalfn: (...args: ToolEvents[K]) => void

        The function that was passed to addEventListener.

      Returns void

    • Call after the pad's display size changes: the pixel size becomes the display size, and existing strokes are scaled proportionally and redrawn.

      Returns Promise<void>

    • Parameters

      • options: { maximumDimensionSize?: number }
        • OptionalmaximumDimensionSize?: number

          Maximum side length of placed signatures in PDF points.

      Returns void

      Use setSignatureScaleFactor. Maximum side length (pt) of signatures placed on the page.

    • Sets the name of the tool.

      Parameters

      • name: string

        The tool name.

      Returns void

    • Sets the full signature: an ink annotation (strokes, color and width copied), an image annotation or dataURL (image signature), or a stroke array; null clears it.

      Parameters

      • signature: SignatureSource
      • OptionalfileSize: number

      Returns Promise<void>

    • Binds the signature pad: press and move on the canvas to write a stroke, release to end it; strokes are added to the current full signature (a new ink when there is none or it is an image).

      Parameters

      • canvas: HTMLCanvasElement

      Returns void

    • Sets the factor by which signatures are scaled when placed on the page. Values that are not positive are ignored with a warning.

      Parameters

      • scale: number

        The scale factor; 1 by default.

      Returns void

    • Sets how signature fields are signed. Throws for unknown modes.

      Parameters

      • mode: SigningModes

        The signing mode.

      Returns void

    • Changes the tool's default style (used by annotations created afterwards); fires toolUpdated.

      Parameters

      • styles: Record<string, unknown>

      Returns void

      const { documentViewer, Annotations, Tools } = instance.Core;
      const freeTextTool = documentViewer.getTool(Tools.ToolNames.FREETEXT);
      freeTextTool.setStyles({ TextColor: new Annotations.Color(0, 0, 0), FontSize: '14pt', Font: 'Helvetica' });
      documentViewer.getTool(Tools.ToolNames.HIGHLIGHT).setStyles({ StrokeColor: new Annotations.Color(0, 255, 0), Opacity: 0.6 });
    • Sets the source of the "Sign here" text (static; handler is called with the tool as this and returns the label text on signature fields). When unset, DocumentViewer draws the default "SIGN HERE" label.

      Parameters

      • textHandler: SignatureTextHandler

      Returns void

    • Previews the signature as the pointer moves; a click places it.

      Returns Promise<void>

    • Switch in: use the tool's own cursor.

      Parameters

      • Optional_oldTool: Tool

      Returns void

    • Switch out: the cursor returns to default.

      Parameters

      • OptionalnewTool: Tool

      Returns void

    • Called on a tap (a touch press and release without moving); does nothing in the base class.

      Parameters

      • _e: PointerEvent

        The pointer event.

      Returns void

    • A listener that throws does not affect the others; the error is reported through logger.error.

      Type Parameters

      • K extends keyof ToolEvents

      Parameters

      • name: K
      • Optionalargs: ToolEvents[K]

      Returns void

    • Like trigger, but awaits the Promise returned by each listener in turn; a failing listener does not affect the others.

      Type Parameters

      • K extends keyof ToolEvents

      Parameters

      • name: K
      • Optionalargs: ToolEvents[K]

      Returns Promise<void>

    ACCEPTED_FILE_SIZE: number | null

    setSignature rejects a file whose given size exceeds this (bytes) and fire fileRejected; null means no limit.

    annotation: Core.Annotations.Annotation | null

    Preview following the pointer (not added to the document).

    cursor: string

    The tool's own cursor: used when switching in and when hovering over empty space (default for the edit tool, crosshair for creation tools, text for text tools, grab for pan...).

    defaults: Record<string, unknown>

    Default style of annotations created by the tool (such as StrokeColor, StrokeThickness, Opacity); changed with setStyles.

    ENABLE_ANNOTATION_HOVER_CURSORS: boolean

    Changes the cursor on hover by what is under the pointer (annotations, handles, text); the stamp, attachment, eraser and marquee zoom tools turn it off, and it is turned back on when they switch out (Tool.ENABLE_ANNOTATION_HOVER_CURSORS).

    ENABLE_AUTO_SWITCH: boolean

    Whether the edit tool selects text automatically when hovering over text (the edit tool selects text itself, so when this is off it neither selects text nor shows the text cursor; the instance enable / disableTextSelection must also be on). Turned off on touch screens.

    Events: {
        ANNOTATION_ADDED: "annotationAdded";
        FILE_REJECTED: "fileRejected";
        LOCATION_SELECTED: "locationSelected";
        SIGNATURE_DELETED: "signatureDeleted";
        SIGNATURE_READY: "signatureReady";
        SIGNATURE_SAVED: "signatureSaved";
    }

    Event names of the signature tool.

    Type Declaration

    • ReadonlyANNOTATION_ADDED: "annotationAdded"

      'annotationAdded': a signature annotation was added to the document.

    • ReadonlyFILE_REJECTED: "fileRejected"

      'fileRejected': setSignature rejected a file larger than ACCEPTED_FILE_SIZE; receives the reason, the limit and the file size.

    • ReadonlyLOCATION_SELECTED: "locationSelected"

      'locationSelected': a position or an empty signature field was clicked without a signature to place; receives the position and the field (or null).

    • ReadonlySIGNATURE_DELETED: "signatureDeleted"

      'signatureDeleted': a saved signature was deleted; receives the signature and its index.

    • ReadonlySIGNATURE_READY: "signatureReady"

      'signatureReady': a signature annotation was created for placing; receives the annotation and its position.

    • ReadonlySIGNATURE_SAVED: "signatureSaved"

      'signatureSaved': signatures were saved; receives the saved signatures.

    location: MouseLocation | null

    Where the next signature goes (recorded when clicking a signature field or the page); cleared after addSignature uses it.

    name: string

    Name the tool is registered under (one of ToolNames).

    SigningModes: typeof SigningModes

    Signing modes of signature fields (same as the SigningModes enum).