Nutrient Web SDK

ReferenceNutrientViewerCustomOverlayItem

Class CustomOverlayItem

This record is used to persist the information for a Custom Overlay Item.

Custom Overlay Items are user defined DOM Nodes that are rendered in a page at a given position.

Class

Example

Creating an image and rendering it as Custom Overlay Item.

let img = document.createElement("img");
img.src = "https://example.com/logo.png";

const item = new NutrientViewer.CustomOverlayItem({
id: "logo-item",
node: img,
pageIndex: 0,
position: new NutrientViewer.Geometry.Point({ x: 100, y: 100 }),
onAppear() {
console.log('rendered!');
}
});

instance.setCustomOverlayItem(item);

See Also

Hierarchy

RecordCustomOverlayItem

Constructors

  • Parameters

    args
    { … }

Properties

boolean

Whether the node should not be zoomed (scaled) with the page.

Custom zoom handling makes sense when you want to display rasterized images for example, and you need to manually re-render them (maybe when using <canvas> images or want to display images at different resolutions).

To track zoom changes and manually update overlay items you can subscribe to the viewState.zoom.change event.

By default items will zoom with the page using a CSS based scale transformation.

Default Value

false
string

A unique identifier to describe the custom overlay item. New IDs should be generated by the user and should be unique.

A reference to the DOM Node to render in the page.

boolean

Whether the node should not be rotated with the page.

onAppear

Optional
((...args: unknown[]) => void) | null

Optional callback to invoke when the custom item is created and appears in the viewport.

onDisappear

Optional
((...args: unknown[]) => void) | null

Optional callback to invoke when the custom item is removed.

number

The page index on which the custom item is placed. It's important to notice that a custom item can only ever be on one page.

Position of this custom item in the page. The coordinates are in the PDF page space with the origin being on the top left.

Immutable Record API

31
string

The name provided to Record(values, name) can be accessed with displayName.

  • Returns

    IterableIterator<
    [
    keyof { … },
    | string
    | number
    | boolean
    | Node
    | NutrientViewer.Geometry.Point
    | ((...args: unknown[]) => void)
    | ((...args: unknown[]) => void)
    | null
    | undefined
    ]
    >
  • Returns

    this

    See Also

    • Map#asImmutable

  • Returns

    this

    See Also

    • Map#asMutable

  • Returns a new instance of this Record type with all values set to their default values.

    Returns

    this
  • Returns a new instance of this Record type with the value for the specific key set to its default value.

    Type Parameters

    K
    extends keyof { … }

    Parameters

    keyK

    Returns

    this
  • Parameters

    keyPathIterable<unknown>

    Returns

    this
  • Parameters

    otherunknown

    Returns

    boolean
  • Returns the value associated with the provided key, which may be the default value defined when creating the Record factory function.

    If the requested key is not defined by this Record type, then notSetValue will be returned if provided. Note that this scenario would produce an error when using Flow or TypeScript.

    Type Parameters

    K
    extends keyof { … }

    Parameters

    keyK
    notSetValueunknown
    Optional

    Returns

    { … }[K]
  • Type Parameters

    T

    Parameters

    keystring
    notSetValueT

    Returns

  • Parameters

    keyPathIterable<unknown>

    Returns

    unknown
  • Parameters

    keystring

    Returns

    key is
    | "id"
    | "pageIndex"
    | "noRotate"
    | "disableAutoZoom"
    | "node"
    | "position"
    | "onAppear"
    | "onDisappear"
  • Returns

    number
  • Parameters

    keyPathIterable<unknown>

    Returns

    boolean
  • Parameters

    ...collections
    (Iterable<[string, unknown], any, any> | Partial<{ … }>)[]

    Returns

    this
  • Parameters

    ...collections
    (Iterable<[string, unknown], any, any> | Partial<{ … }>)[]

    Returns

    this
  • Parameters

    keyPathIterable<unknown>
    ...collectionsunknown[]

    Returns

    this
  • Parameters

    merger(oldVal: unknown, newVal: unknown, key: unknown) => unknown
    ...collections
    (Iterable<[string, unknown], any, any> | Partial<{ … }>)[]

    Returns

    this
  • Parameters

    keyPathIterable<unknown>
    ...collectionsunknown[]

    Returns

    this
  • Parameters

    merger
    (oldVal: unknown, newVal: unknown, key: keyof { … }) => unknown
    ...collections
    (Iterable<[string, unknown], any, any> | Partial<{ … }>)[]

    Returns

    this
  • Type Parameters

    K
    extends keyof { … }

    Parameters

    keyK

    Returns

    this
  • Parameters

    keyPathIterable<unknown>

    Returns

    this
  • Type Parameters

    K
    extends keyof { … }

    Parameters

    keyK
    value
    { … }[K]

    Returns

    this
  • Parameters

    keyPathIterable<unknown>
    valueunknown

    Returns

    this
  • Deeply converts this Record to equivalent native JavaScript Object.

    Note: This method may not be overridden. Objects with custom serialization to plain JS may override toJSON() instead.

    Returns

    { … }
  • Shallowly converts this Record to equivalent native JavaScript Object.

    Returns

    { … }
  • Shallowly converts this Record to equivalent JavaScript Object.

    Returns

    { … }
  • Returns

    Keyed<
    keyof { … },
    | string
    | number
    | boolean
    | Node
    | NutrientViewer.Geometry.Point
    | ((...args: unknown[]) => void)
    | ((...args: unknown[]) => void)
    | null
    | undefined
    >
  • Type Parameters

    K
    extends keyof { … }

    Parameters

    keyK
    updater
    (value: { … }[K]) => { … }[K]

    Returns

    this
  • Parameters

    keyPathIterable<unknown>
    updater(value: unknown) => unknown

    Returns

    this
  • Returns

    boolean

    See Also

    • Map#wasAltered

  • Note: Not all methods can be used on a mutable collection or within withMutations! Only set may be used mutatively.

    Parameters

    mutator(mutable: this) => unknown

    Returns

    this

    See Also

    • Map#withMutations