pdf.js: Changing current page number programmatically - pdf.js

With pdf.js is there a way to programmatically change the current page of a PDF being viewed? For example, a call to change the current page to page 5.
(I know that I can initially set the page by specifying the page number in the URL, but I want to change it programmatically after it has been opened.)

PDFViewerApplication.pdfViewer.currentPageNumber is a getter and setter. Examples:
// Go to page 5
PDFViewerApplication.pdfViewer.currentPageNumber = 5;
// Move two pages forward
PDFViewerApplication.pdfViewer.currentPageNumber += 2;

Related

TJvWizard how to change page to specific TJvWizardInteriorPage?

is it possible to change to a specific interior page on the wizard?
lets say I'm on page 2 and I want to move to 5 directly without the user clicking next button 3 times.
thanks!

Scroll bar in LibreOffice dialog

I am trying to make an image picker component in LibreOffice.
I have a dialog that is dynamically filled with images. When the user clicks on one images, it should be selected and the dialog should be closed.
The problem is that the number of images is variable. So I need to enable scrolling in the dialog (so that the user can navigate through all images).
There seems to be some properties on the dialog object (Scrollbars, Scroll width, Scroll height, etc)
However, I cannot find a way to use them anywhere.
Any ideas?
The scrollbar is one of the Controls available through the dialog box editor. That is the easier way to put a ScrollBar on a dialog box. Just insert it like any other control. There is a harder way via DialogModel.addControl but that seems non-essential to answering this question.
If you add a scrollbar to the dialog box and run the dialog box, you will find it does nothing by default. The functionality (apparently) must be written into a macro. The appropriate triggering event is the While Adjusting event on the ScrollBar object, although it does not trigger the macro simply with the "Test Mode" function in the dialog editor. Running the dialog box through a macro triggers the While Adjusting event when the scroll arrows are triggered, when the slider area is clicked to move the slider, and when the slider itself is dragged. The Object variable returned by the scrollbar event contains a property .Value which is an absolute value between 0 and the EventObject.Model.ScrollValueMax, which allows you to manipulate the other objects on the page manually based on the position of the slider.
Yes, that's right, manipulate objects manually. The sole example I found, from the LibreOffice 4.5 SDK, does precisely this. Of course, it is not as bad as it sounds, because one can iterate through all of the objects on the page by reading the array Dialog.getControls(). In any event, the secret sauce of the example provided in the SDK is to define Static variables to save the initial positions of all of the objects you manipulate with the scrollbar and then simply index those initial positions based on a ratio derived from the scrollbar Value divided by the ScrollValueMax.
Here is a very simple working example of how to scroll. This requires a saved Dialog1 in the Standard library of your document, which contains an object ScrollBar1 (a vertical scrollbar) and Label1 anywhere in the dialog. The ScrollBar1 must be configured to execute the macro ScrBar subroutine (below) on the While Adjusting event. Open the dialog by executing the OpenDialog macro and the scrollbar will move the Label1 control up and down in proportion to the page.
Sub OpenDialog
DialogLibraries.LoadLibrary("Standard")
oVariable = DialogLibraries.Standard.Dialog1
oDialog1 = CreateUnoDialog( oVariable )
oDialog1.Execute()
End Sub
Sub ScrBar (oEventObj As Object)
Static bInit As Boolean
Static PositionLbl1Y0 As Long
oSrc = oEventObj.Source
oSrcModel = oSrc.Model
scrollRatio = oEventObj.Value / oSrcModel.ScrollValueMax
oContx = oSrc.Context
oContxModl = oContx.Model
oLbl1 = oContx.getControl("Label1")
oLbl1Model = oLbl1.Model
REM on initialization remember the position of the label
If bInit = False Then
bInit = True
PositionLbl1Y0 = oLbl1Model.PositionY
End If
oLbl1Model.PositionY = PositionLbl1Y0 - (scrollRatio * oContx.Size.Height)
End Sub
The example provided by the SDK does not run on my setup, but the principles are sound.
There appears to be a second improvised method closer to the functionality one might expect. This method uses the DialogModel.scrollTop property. The property appears to iterate the entire box up or down as a scroll based on the user input. There are two problems using this methodology, however. First, unless you put the scrollbar somewhere else, the scroll bar will scroll away along with the rest of the page. You will need to adjust the location of the scrollbar precisely to compensate for/negate the scrolling of the entire page. In the example below I tried but did not perfect this. Second, the property seems to miss inputs with frequency and easily goes out of alignment/ enters a maladjusted state. Perhaps you can overcome these limitations. Here is the example, relying on the same setup described above.
Sub ScrBar (oEventObj As Object)
Static scrollPos
oSrc = oEventObj.Source
oSrcModel = oSrc.Model
scrollRatio = oEventObj.Value / oSrcModel.ScrollValueMax
If IsEmpty(scrollPos) = False Then
scrollDiff = oEventObj.Value - scrollPos
Else
scrollDiff = oEventObj.Value
End If
scrollPos = oEventObj.Value
oContx = oSrc.Context
oContxModl = oContx.Model
oContxModl.scrollTop = scrollDiff * -1
oSrcModel.PositionY=(scrollRatio * oContx.Size.Height/5) * -1
End Sub
This (sort of) will scroll the contents of the entire dialog box, within limits and with the caveats noted above.

jquerymobile, update dynamically a page and reset scroll position

I'm trying to dynamically update the content of a page with jquery mobile ( $('#testpage').page('destroy').page(); ), and reset the scroll position ( $.mobile.silentScroll(0); ).
It works but for a few milliseconds, jquery shows the new content scrolled down at the old position. I wish to show the new content directly scrolled at the top of the page.
There must be a parameter in jquery that remembers the scroll position when you call $('#testpage').page('destroy').page();, and I wish to reset this parameter.
Maybe I'm having the wrong approach, and I should use 2 separated divs for the 2 pages.
The reason I'm doing this is because I want the hash in the url being the same for the 2 pages, and I don't want the user being able to go back to the previous page with the browser back action. If I can achieve this with 2 separated divs, that would be fine too.
Here is a jsfiddle to illustrate : http://jsfiddle.net/EKFSy/2/
I replaced $.mobile.silentScroll(0); with $.mobile.changePage( $('#testpage') , {allowSamePageTransition:true} ); and it worked.
Note that I also tried to play with $.mobile.urlHistory.getActive().lastScroll. It was not necessary in my case to set it to zero (because it seems changePage on the same page already reset the scroll position), but that might be a useful value to play with if you want to change the scroll positions in your history.
http://jsfiddle.net/EKFSy/3/

Disable TAB key for all controls in asp.net mvc

I have an asp.net MVC project with multiple pages.
For each page I must set the TAB key to go only among some controls. I know I can set:
tabIndex=x , x > 0 //to enable
tabIndex=-1, //to disable
The problem is that I have 5 controls for which the TAB key should work and 50 controls for which it should not work (the numbers are just to understand the proportions). So I was wondering if there is a way to disable the TAB key for an entire page (from *.css or a manager) and than make it enable just for the few specific controls that need it.
As far as I know this cannot be done as directly as you probably hope. What you can consider doing is executing a JS function on all elements where the tab index not set, setting it to less than zero:
var elements = document.querySelectorAll("input:not([tabindex])");
for (var i = 0; i < elements.length; i++) {
elements[i].tabindex = -1;
}
Keep in mind that depending on the number of elements that you have, this could be a drag on performance so you will want to consider benchmarking.
The other option that you could consider would be to create an HTML helper server-side which disables the tab index of the element. You can do helpers locally using the Razor #helper syntax, or globally using an extension method on the HtmlHelper class. This would perform significantly better than JS but may be a bit heavy handed depending on your scenario.
Since there were so many elements that should not be tabbed, instead or disabling TAB key for them, I changed the default behavior for the elements that had tabIndex, onkey pressed:
1) I took all elements that have tabIndex bigger than 0:
var tabbables = document.querySelectorAll("input[tabindex], textarea[tabindex]");
this is a simplified version, you should do visibility checks and select also other types of elements (e.g. buttons, etc.)
2) I replaced the default behavior in 2 cases: TAB presssed and the last element with tab index is selected or SHIFT+TAB is pressed and first element is selected. For these cases I forced the focus on the first element, respectively on the last element.
A similar question with a very good answer (not the accepted answer, the answer with most votes) is here: "Focus Next Element In Tab Index"

How do you rename a Status Bar Panel in Delphi 2010

I have just added a new panel to StatusBar1 and it is called 5 - TStatusPanel. I want to give it a different name but I can't remember how to do this.
I want to rename 5 - TStatusPanel to 5 - GripArea. As you can see from the image I have done this before (see Num, Caps, AM/PM) but I can't remember how I did this. It sucks to get old.
Just change the Text property of the TStatusPanel. This is what is displayed in the status panel editor. Of course, this will make the text visible in the panel! Normally, in code, you access the status panels using the StatusBar1.Panels[PanelIndex] array. PanelIndex is the zero-based index of the panel. I always declare constants such as
STATUS_FILE_POSITION = 0;
STATUS_FILE_SAVED = 1;
STATUS_LONG_TEXT = 2;
STATUS_ZOOM_CONTROL = 3;
and use these to remember the panels. (The code above is from my text editor.)
So I can do, for instance,
StatusBar.Panels[STATUS_FILE_SAVED].Text := 'Modified';
Here's a tip that would have saved some hunting: right-click on the form, View As Text. Now you'll see the form layed out as properties, and you could have found the control, seen how the other panels were named, and fix the last one.
Alt+F12 to toggle the text view on/off.

Resources