WDV Snippet Delete Annotations

From SupportWiki
Jump to: navigation, search


Code to delete all selected annotations

// assumes your WDV is named "_viewer"
// Deletes all selected annotations on any page
function deleteSelectedAnnotations() {            
    for (var pg = 0; pg < _viewer.getDocumentInfo().count; pg++) {
               deleteSelectedAnnotations(pg);
    }
}


If you jsut want to delete all selected annotations on a given page

// assumes your WDV is named "_viewer"
// deletes selected annotations on a single page
function deleteSelectedAnnotations(pg) {            
    var pageAnnos = _viewer.getAnnotationsFromPage(pg);
    if (pageAnnos.length > 0) {
        for (var annoIndex = pageAnnos.length - 1; annoIndex >= 0; annoIndex--) {
            if (pageAnnos[annoIndex].selected) {
                _viewer.annotations.deleteFromPage(pg, annoIndex);
            }
        }
    }
}