PDF Generation Template Editor
Open-source visual PDF generation engine with customizable templates and developer-friendly APIs.
Open-source visual PDF generation engine with customizable templates and developer-friendly APIs.
The (0, 0) point is located at the top left of the page in WebViewer. The x axis extends horizontally to the right and the y axis extends vertically downward.
const pageNumber = 1;
const pagePoint = {
x: 0,
y: 0
};
const windowPoint = docViewer.pageToWindow(pagePoint, pageNumber);
// { x: 47, y: 64 }const pageNumber = 1;
const windowPoint = {
x: 47,
y: 64
};
const pagePoint = docViewer.windowToPage(windowPoint, pageNumber);
// { pageNumber: 1, x: 0, y: 0 }const getMouseLocation = e => {
const scrollElement = docViewer.getScrollViewElement();
const scrollLeft = scrollElement.scrollLeft || 0;
const scrollTop = scrollElement.scrollTop || 0;
return {
x: e.pageX + scrollLeft,
y: e.pageY + scrollTop
};
}
const handleClick = (e) => {
let windowCoordinates = getMouseLocation(e);
const page = docViewer.getSelectedPage(windowCoordinates, windowCoordinates);
const clickPageNumber = (page.first !== null) ? page.first : docViewer.currentPageNumber;
const pagePoint = docViewer.windowToPage(windowCoordinates, clickPageNumber);
}
docViewer.addEvent('click', handleClick);