PDF Embed API - Get Selected text from annotation.

New Here ,
Jan 19, 2022 Jan 19, 2022

Copy link to clipboard

Copied

Hi ,


When adding an annotation, is it possible to get the selected text from that annotation ?

 

I am getting the text from getSelectedContent() on selection, but when highlighting getSelectedContent() is giving empty data.

 

Any help in this would be greatly appreciated!

TOPICS
Edit and convert PDFs , JavaScript , Standards and accessibility

Views

210

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 ,
Apr 16, 2022 Apr 16, 2022

Copy link to clipboard

Copied

You need to use getSelectedContent() after "PREVIEW_SELECTION_END" event is fired. 

adobeDCView.registerCallback(
        AdobeDC.View.Enum.CallbackType.EVENT_LISTENER,
        function(event) {
            if (event.type === "PREVIEW_SELECTION_END") {
                previewFilePromise.then(adobeViewer => {
                    adobeViewer.getAPIs().then(apis => {
                        apis.getSelectedContent()
                            .then(result => console.log(result));
                    });
                });
            }
        }, {enableFilePreviewEvents: 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
New Here ,
May 27, 2022 May 27, 2022

Copy link to clipboard

Copied

LATEST

this solution does not work on annotated text, works only on normal text selection.. any help to get the selected text from annotation ?

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
LEGEND ,
Apr 16, 2022 Apr 16, 2022

Copy link to clipboard

Copied

Note that the correct forum for posts about the PDF Embed API is https://community.adobe.com/t5/document-services-apis/ct-p/ct-Document-Cloud-SDK - using the wrong forum may cause long delays or no reply.

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