Get current page view/viewport as an image

Q: How do I get the current page view/viewport as an image?

A:

documentContainer = instance.Core.documentViewer.getScrollViewElement();

topLeft = {
    x: documentContainer.offsetLeft + documentContainer.scrollLeft,
    y: documentContainer.offsetTop + documentContainer.scrollTop
};
botRight = {
    x: documentContainer.offsetLeft + documentContainer.scrollLeft + documentContainer.clientWidth,
    y: documentContainer.offsetTop + documentContainer.scrollTop + documentContainer.clientHeight
};

topLeftPageCoordinate = displayModeManager.windowToPage(topLeft, docViewer.getCurrentPage() - 1);
bottomRightPageCoordinate = displayModeManager.windowToPage(botRight, docViewer.getCurrentPage() - 1);

docViewer.getDocument().loadCanvasAsync({
    pageIndex: docViewer.getCurrentPage() - 1,
    pageRotation: docViewer.getRotation(),
    getZoom: function() {
        return docViewer.getZoom();
    },
    drawComplete: function(canvas) {
        canvas.toDataURL();
    },
    renderRect: {
        x1: topLeftPageCoordinate.x,
        y1: topLeftPageCoordinate.y,
        x2: bottomRightPageCoordinate.x,
        y2: bottomRightPageCoordinate.y
    },
});

Hello, I’m Ron, an automated tech support bot :robot:

While you wait for one of our customer support representatives to get back to you, please check out some of these documentation pages:

Guides:APIs:Forums: