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
},
});