Nutrient Web SDK

v0.0.0-dev

Function unload

Unloads an existing NutrientViewer instance.

It requires an target parameter that is a CSS selector, an HTMLElement or the reference to a NutrientViewer.Instance returned by NutrientViewer.load.

Function
Type Signature
unload(target: string | NutrientViewer.Instance | HTMLElement | null): boolean
  • Type Declaration

    Parameters

    targetstring | NutrientViewer.Instance | HTMLElement | null

    A target to unload

    Returns

    boolean

    When true, an instance of Nutrient Web SDK was unmounted.

    Example

    Unload Nutrient Web SDK using an instance
    let instance = null;
    NutrientViewer.load({
    document: "/sales-report.pdf",
    container: ".foo",
    }).then((i) => {
    instance = i
    })
    .then(() => {
    // Unload the given instance
    NutrientViewer.unload(instance)
    }).catch((error) => {
    console.error(error.message);
    })
    Unload Nutrient Web SDK using a CSS selector
    NutrientViewer.load({
    document: "/sales-report.pdf",
    container: ".foo",
    })
    .then(() => {
    // Unload the given instance
    NutrientViewer.unload(".foo")
    })
    Unload Nutrient Web SDK using an HTMLElement
    NutrientViewer.load({
    document: "/sales-report.pdf",
    container: ".foo",
    })
    .then(() => {
    // Unload the given instance
    NutrientViewer.unload(document.querySelector(".foo"))
    })

    @public

    Errors

    Will throw an error when the target is invalid but will work when it does not have a mounted Nutrient Web SDK instance.