Embed Template in an iFrame

The generated URL can be embedded within your website using the iFrame HTML element, and some parts of the embedded create template page can be controlled using client side triggers.

<iframe
    id = "prepare_page"
    src = "https://app.boldsign.com/document/embed/?templateId=6a154b94..."
    height = "100%"
    width = "100%"
    class = "frame">
</iframe>

Client side triggers

Client side triggers are special commands that are used to control the embedded create template page loaded in your website's iFrame element.

There are currently 4 triggers available, and they are listed below.

onNextClickThis trigger is used to move the embedded create template page from FillingPage to PreparePage. It will only function if the current page is FillingPage.
onPreviewClickThis trigger is used to navigate to the preview document page, where your user can view the document from each role's perspective. It will work only when the current page is PreparePage.
onSaveAndCloseClickThis trigger is used to save the current state of the template as a draft and completes the template creation process. This trigger requires the ShowSaveButton to be set to true during the URL generate request and current page to be PreparePage.
onSendClickThis trigger is used to finalize the template creation process. This trigger requires the ShowSendButton to be set to true during the URL generate request and current page to be PreparePage.

Usage

<div>
    <button onclick="onNextClick()">Configure fields</button>
    <button onclick="onPreviewClick()">Preview template</button>
    <button onclick="onSaveAndCloseClick()">Save and close</button>
    <button onclick="onSendClick()">Create template</button>
</div>
<script>
    var iframeEle = document.getElementById("prepare_page");

    function onNextClick() {
        iframeEle.contentWindow.postMessage("onNextClick", "*");
    }

    function onPreviewClick() {
        iframeEle.contentWindow.postMessage("onPreviewClick", "*");
    }

    function onSaveAndCloseClick() {
        iframeEle.contentWindow.postMessage("onSaveAndCloseClick", "*");
    }

    function onSendClick() {
        iframeEle.contentWindow.postMessage("onSendClick", "*");
    }
</script>

Client side events

Client side event are special events that are triggered from the embedded request page to the host/parent (Your website).

There are currently 4 events available, which are listed below.

OnDraftSavedSuccessThis event will be triggered when the user selects the Save & Close option from the More Action drop down menu and the template draft save process is successful.
onDraftFailedThis event is triggered when the user selects the Save & Close option from the More Action drop down menu but the draft save process fails.
onCreateSuccessThis event will be triggered when the user clicks the Create template button and the template creation process is successful.
onCreateFailedThis event will be triggered when the user clicks the "Create template" button but the template creation process fails.
onTemplateEditingCompletedThis event will be triggered when the user clicks the save template button, and the template editing process is successful.
onTemplateEditingFailedThis event will be triggered when the user clicks the save template button, and the template editing process is failed.

Usage

<script>
    window.addEventListener("message", function (params) {
        if (params.origin !== "https://app.boldsign.com") {
            return;
        }

        switch (params.status) {
            case "OnDraftSavedSuccess":
                // handle draft success
                break;
            case "onDraftFailed":
                // handle draft failure
                break;
            case "onCreateSuccess":
                // handle create success
                break;
            case "onCreateFailed":
                // handle create failure
                break;
            case "onTemplateEditingCompleted":
                // handle edit success
                break;
            case "onTemplateEditingFailed":
                // handle edit failure
                break;
            default:
                break;
        }
    });
</script>

Best practices

There are some best practices to follow when incorporating the embedded request URL into your application to provide the best user experience possible.

  • Allow BoldSign to take complete control of the browser window.
  • If you decide to use the iFrame sizing, ensure sure that recommended minimum width and height are 1360 and 768 respectively are met.

Webhooks

Please refer Webhooks article to subscribe to template events.

If you have subscribed to the Template Create event, your URL will receive a webhook request when the template creation process is finished. You can synchronize any changes that were made in the embedded process within your application or database.