Programmatically Toggle Comments Panel in PDF Embed API Viewiwer

New Here ,
Feb 07, 2021 Feb 07, 2021

Copy link to clipboard

Copied

Hello,

 

Is there a way to toggle the Annotation's Comment Panel programatically?

gedsmurf1_0-1612764414177.png

We want the Comments Panel to be shown/hidden depending on some application settings.

 

Thanks

TOPICS
PDF Embed API

Views

181

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct Answer

Adobe Community Professional , Feb 08, 2021 Feb 08, 2021
You can disable the comments pane using setting showCommentsPanel to false in the SetConfig object.

Likes

Translate

Translate
Adobe Employee ,
Feb 07, 2021 Feb 07, 2021

Copy link to clipboard

Copied

Hi, Thanks for using PDF Embed API. Please look for setConfig API under section APIs to control UI configurations in the documentation.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 08, 2021 Feb 08, 2021

Copy link to clipboard

Copied

Thank you for your response, I looked at the documentation but I am not sure which constant it is.

gedsmurf1_0-1612780623811.png

 

gedsmurf1_1-1612780713911.png

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Feb 08, 2021 Feb 08, 2021

Copy link to clipboard

Copied

You can disable the comments pane using setting showCommentsPanel to false in the SetConfig object.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 09, 2021 Feb 09, 2021

Copy link to clipboard

Copied

Can we call setConfig after the previewFile? Which object has the setConfig method?

We want to call the setConfig when a page button is clicked.

 

 
document.addEventListener("adobe_dc_view_sdk.ready", function () {
	var adobeDCView = new AdobeDC.View({ clientId: pdfInfo.adobeClientId, divId: "adobe-dc-view" });
    var previewFilePromise = adobeDCView.previewFile({
        content: {
            location: { url: fileUrl }
        },
        metaData: {
            fileName: pdfInfo.name || "file.pdf",
            id: pdfInfo.id || "file1" 
        } 
    }, {
        enableAnnotationAPIs: true,
    });

    previewFilePromise.then(adobeViewer => {
        adobeViewer.getAnnotationManager().then(annotationManager => {
            // All annotation APIs can be invoked here
            console.log("loading annotations ....")

            return loadDocumentAnnotations(pdfInfo.url).then(function (listOfAnnotations) {
                console.log("List of annotations from db ", listOfAnnotations);
                if (listOfAnnotations && listOfAnnotations.length) {
                    annotationManager.addAnnotations(listOfAnnotations).then(function () {
                        registerAnnotationEventListeners(annotationManager);
                    });
                } else {
                    registerAnnotationEventListeners(annotationManager);
                }
             
                var note = window.pdfInfo.note;
                if (note) {
                    annotationManager.selectAnnotation(note);
                }
            }).catch(function(){
                registerAnnotationEventListeners(annotationManager);
            }); 
        });

        adobeViewer.getAPIs().then(function (apis) {
            if (window.pdfInfo.page) {
                var x = Number(pdfInfo.x || 0);
                var y = Number(pdfInfo.y || 0);
                var page = Number(page) || 1;

                setTimeout(function () {
                    apis.gotoLocation(page, x, y);
                }, 800);
            };
			window.AdobeViewerApi = apis;
         });
    });
	
	window.AdobeViewer = adobeDCView;
});


document.getElementById("showCommentsPanelButton").addEventListener("click", function(e){
	//we want something like this but there is no setConfig for both AdobViewer and AdobeViewerApi
	AdobeViewer.setConfig({showCommentsPanel: true });
	AdobeViewerApi.setConfig({showCommentsPanel: true });
});

document.getElementById("hideCommentsPanelButton").addEventListener("click", function(e){
	//we want something like this but there is no setConfig for both AdobViewer and AdobeViewerApi
	AdobeViewer.setConfig({showCommentsPanel: false });
	AdobeViewerApi.setConfig({showCommentsPanel: false });
});

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 09, 2021 Feb 09, 2021

Copy link to clipboard

Copied

Nevermind, I found it now it is on the annotationManager object.

 

Thank you very much!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 09, 2021 Feb 09, 2021

Copy link to clipboard

Copied

LATEST

Btw, both methods works:

 

annotationManager.setConfig({ showCommentsPanel: true });

AdobeViewer.executeCommand('TOGGLE_COMMENTING', true);

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines