Description This function returns the list of bookmark links of a pdf document. It is possible to bind the JSON list and navigate pages of a pdf file. The function is a JavaScript Promise. Below is a sample code snippet that describes how to bind the pdf bookmark data in your web page. Note: the snippet uses JsTree a jquery pluginto bind the bookmark tree in the web page.
<script type="text/javascript" src="api_js/jstree.js"></script>
PanoramaAPI.getBookmarkJSON().then(function (data) {
    if (data == null) {
        htm = "Error to retrive PDF Bookmark"
        $("#divIDtoBindBookmarks").html('<p class="api-error">' + htm + '</p>');
    }
    else {
        var dataObj = JSON.parse(data);
        if (dataObj.list[0].text == "PDF contains no Bookmark!") {
            htm = "PDF contains no Bookmark"
            $("#divIDtoBindBookmarks").html('<p class="api-error">' + htm + '</p>');
        }
        else {
            if (dataObj != null) {
                $("#divIDtoBindBookmarks")
                    .jstree('destroy')
                    .jstree({
                        'core': {
                            'data': dataObj.list,
                            "multiple": false,
                            "animation": 0,
                            'state': {
                                'opened': true,
                                'selected': true
                            },
                        },
                        "plugins": ["themes", "json_data"]
                    })
                    .bind("changed.jstree", function (e, data) {
                        var currentPageNO = data.node.original.pageNo;
                        if (currentPageNO != null || currentPageNO != "") {
                            var pageNo = parseInt(currentPageNO.match(/[0-9]+/)[0], 10);
                            PanoramaAPI.currentPageNumber = pageNo;
                        }
                        PanoramaAPI.goToPage(PanoramaAPI.currentPageNumber);
                    })
                    .bind("loaded.jstree", function (event, data) {
                        data.instance.open_all();
                    });
            }
        }
        $("#divIDtoBindBookmarks").css("overflow-x", "scroll");
    }
}).catch(function (error) {
});
Syntax PanoramaAPI.getBookmarkJSON()
Parameters NA
Returns GetPdfBookmarkResult:JavaScriptObject { "GetPdfBookmarkResult": { "list": [{ "id": "#0", "parent": "#", "text": "Bookmark", "pageNo": null, "icon": null }, { "id": "#01", "parent": "#0", "text": "Contents", "pageNo": "1", "icon": null }, { "id": "#02", "parent": "#0", "text": "High Accuracy and Reliability for Control Applications", "pageNo": "2", "icon": null }, { "id": "#023", "parent": "#02", "text": "Digital Field Devices that power PlantWeb", "pageNo": "2", "icon": null }, .... ], "errorStatus": false, "errorType": null } }

Feedback

Was this helpful?

Yes No
You indicated this topic was not helpful to you ...
Could you please leave a comment telling us why? Thank you!
Thanks for your feedback.

Post your comment on this topic.

Post Comment