Skip to content

@require-modules ​

The @require-modules directive checks whether a module exists. If not, the marked component is not parsed and is ignored.

Code example ​

When you run the example below, no button appears because the file-property add-on is not loaded.

html
<html>
<template id="layout-template">
    <webpdf>
        <group-list>
            <!-- 'fpmodule' is a module defined in the 'file-property' addon which is not declared in the `addons:[]`, this group component will not be rendered  -->
            <group name="file-property" @require-modules="fpmodule">
                <fpmodule:file-property-button></fpmodule:file-property-button>
            </group>
        </group-list>
        <div class="fv__ui-body">
            <viewer></viewer>
        </div>
        <template>
            <fpmodule:file-property-dialog></fpmodule:file-property-dialog>
        </template>
    </webpdf>
</template>
</html>
<script>
    var CustomAppearance = UIExtension.appearances.Appearance.extend({
        getLayoutTemplate: function () {
            return document.getElementById('layout-template').innerHTML;
        }
    });
    var libPath = window.top.location.origin + '/lib';
    var pdfui = new UIExtension.PDFUI({
        viewerOptions: {
            libPath: libPath,
            jr: {
                licenseSN: licenseSN,
                licenseKey: licenseKey
            }
        },
        renderTo: document.body,
        appearance: CustomAppearance,
        addons: [] / No addon is loaded
    });
    var origin = window.top.location.origin;
    var url = origin + window.top.location.href.slice(origin.length).replace(/((\/.*)?\/docs\/).*/, '$1FoxitPDFSDKforWeb_DemoGuide.pdf');
    pdfui.openPDFByHttpRangeRequest({
        range: {
            url: url,
        }
    }, {fileName: 'FoxitPDFSDKforWeb_DemoGuide.pdf'})

    window.addEventListener(UIExtension.PDFViewCtrl.DeviceInfo.isDesktop ? 'resize' : 'orientationchange', function (e) {
        pdfui.redraw().catch(function (err) {
            console.log(err)
        });
    });
</script>
json
{
  "iframeOptions": {
    "style": "height: 500px"
  }
}

When you run the example below, File Property appears because the add-on is loaded.

html
<html>
<template id="layout-template">
    <webpdf>
        <group-list>
            <group name="file-property" @require-modules="fpmodule">
                <fpmodule:file-property-button></fpmodule:file-property-button>
            </group>
        </group-list>
        <div class="fv__ui-body">
            <viewer></viewer>
        </div>
        <template>
            <fpmodule:file-property-dialog></fpmodule:file-property-dialog>
        </template>
    </webpdf>
</template>
</html>
<script>
    var CustomAppearance = UIExtension.appearances.Appearance.extend({
        getLayoutTemplate: function () {
            return document.getElementById('layout-template').innerHTML;
        }
    });
    var libPath = window.top.location.origin + '/lib';
    var pdfui = new UIExtension.PDFUI({
        viewerOptions: {
            libPath: libPath,
            jr: {
                licenseSN: licenseSN,
                licenseKey: licenseKey
            }
        },
        renderTo: document.body,
        appearance: CustomAppearance,
        addons: [
            libPath + '/uix-addons/file-property'
        ] / the `file-property` addon will be loaded
    });
    var origin = window.top.location.origin;
    var url = origin + window.top.location.href.slice(origin.length).replace(/((\/.*)?\/docs\/).*/, '$1FoxitPDFSDKforWeb_DemoGuide.pdf');
    pdfui.openPDFByHttpRangeRequest({
        range: {
            url: url,
        }
    }, {fileName: 'FoxitPDFSDKforWeb_DemoGuide.pdf'})

    window.addEventListener(UIExtension.PDFViewCtrl.DeviceInfo.isDesktop ? 'resize' : 'orientationchange', function (e) {
        pdfui.redraw().catch(function (err) {
            console.log(err)
        });
    });
</script>
json
{
  "iframeOptions": {
    "style": "height: 500px"
  }
}