Hello!
Using PDF.js Express Viewer, I need the opened PDF-s be zoomed in at a certain area of the first page. Can it be done?
I figured out how a newly loaded document appears zoomed. But I cannot figure out how to scroll to a certain part of the page.
(Short explanation: we display old newspaper pages, but users are only interested in certain articles on the pages.)
My code:
<script>
WebViewer({
path: 'PDF/lib',
licenseKey: 'xxxxxxxxxxxxxxx',
disabledElements: [
'leftPanelButton','searchPanel','selectToolButton','searchButton','viewControlsButton','marqueeToolButton','themeChangeButton','contextMenuPopup'
],
initialDoc: 'mypdf.pdf',
// initialDoc: '/path/to/my/file.pdf', // You can also use documents on your server
}, document.getElementById('viewer'))
.then(instance => {
// now you can access APIs through the WebViewer instance
const { Core, UI } = instance;
instance.UI.setLanguage('hu');
// adding an event listener for when a document is loaded
Core.documentViewer.addEventListener('documentLoaded', () => {
console.log('document loaded');
instance.setZoomLevel(<% =Left(myzoomlevel, 1) & "." & Right(myzoomlevel, 2) %>);
})
});
</script>
Thank you in advance!