It will depend on the PDF viewer you are using. If it is rendering it to HTML, you can likely use the
scrollTop of the overall enclosing element, which you might access something like this:
var scrollPos = document.getElementById('page-container').scrollTop.toString()
Where “page-container” is whatever element in your PDF viewer is the enclosing elements for the pages.
To reset it when you return, you’d just set this saved value using
Or use an array of HTMLViewers each inside a PagePanel page?
I am developing on MacOS. I have an HTMLViewer control, ‘hview’, and to display the PDF, I do:
hview.LoadURL( “file://[path to the file].pdf” )
If I switch to viewing a different PDF in hview, I would like to get the scroll settings of the current page. If I ever go back to viewing the first PDF, I would like to restore it to the scroll settings it had when last it was displayed.
Yeah, I thought about that, but I might easily have thirty PDFs that I am cycling through - I’m writing a program to help with grading tests - and having an HTMLViewer for each, and each one loaded, … I can’t imagine that would be a good thing, performance-wise. Admittedly though, I’ve not actually tried it. :^)
I might look into PDF.js, but first I will play with the other suggestion – using an array of HTMLViewer controls and flipping through them as needed – if only to see what kind of performance hit I take. Thanks!
I am curious, David: what might be the advantage of putting them into pages in a PagePanel control, rather than putting them directly on the main window and setting Visible = False for all but the current one?
[programs a little] Ahhhh, perhaps because, with PagePanel, you need only say that the desired panel is visible: you don’t have to make sure all the others are not visible.
Yes, it is easy to program and conceptually. It is simpler too if you have multiple items to show/hide eg Buttons, Labels.
I was having some issues with PagePanel, so I figured, as each page held only one HTMLViewer (no other controls), I’d forego the PagePanel, make an array of HTMLViewers, and try doing selection by just marking all as not visible and then marking the desired one visible. It works without any visible hitch. My test - 25 PDFs, ranging in size from 660kb to 28Mb - went smoothly, and the scroll positions were maintained. It appears I should have simply gone with the solution I thought of, which was also your suggestion of using an array of HTMLViewers, and not worried about performance until & unless I saw that it was a problem.