With a script, how to scroll to the top in an interactive PDF container?

Hi,

As far as I have tested, the issue is a Mac OS problem only.

  • I am loading A4 PDF files into a container field using the MBS plugin.
  • The height of the Interactive container I use for displaying it is smaller than that of a portrait A4. (width x height = 870 x 744, so I only have a vertical scrollbar).
  • When first displayed, the PDF is scrolled down to show the centre of it, while I want it to show the top. (The documents are not images but standard pages with text).

I can manually fix this by clicking in the field and then pressing Page up, and I am now trying to emulate that in the script loading the PDF from the disk.

In the script, I go to the Object, no problem, but I can't emulate the Page up key.
First, is there an easy solution to this problem I missed? Something already there I am unaware of?

What I have done so far:
I am using the MBS plugin extensively and have tried the function RemoteControl.PressKey, and get it to work in text fields.
I have verified that the virtual key is
kVK_PageUp = 0x74, decimal 116,
and that key should be keyboard independent. (My customers and I use Swedish keyboards).
MBS( "RemoteControl.PressKey" ; 74 )
MBS( "RemoteControl.PressKey" ; "#74" )
MBS( "RemoteControl.PressKey" ; 116 )
I know what Scan codes are, but I have never worked with them. The example in the documentation for pressing the return key is:
MBS( "RemoteControl.PressKey"; 36; 13)
I recognise 13 = #0D for a carriage return, but what is 36?
I am sure I am missing something vital here.

A frustrating problem, such a small thing, and I have already spent a lot of time trying to solve it. So any help or insights would be much appreciated! Thanks!

FileMaker version 2023?

With current MBS Plugin, you can name the layout item and use our web viewer scroll functions.

e.g.
MBS("WebView.Scrollbar.getVerticalPosition"; "container")

and scroll to top:
MBS("WebView.Scrollbar.set"; "web"; 0; 0)

Thanks!

No, FileMaker 18 and 19.

That was a completely different way to go, and I will try that during the weekend :smiley:

I have now tested and realised that the functions suggest is for a MBS web viewer, while I need to get it to work in an interactive (PDF) container inside FileMaker.

Any more suggestions? Anyone know the virtual key and scan code for Page up on Mac OS?

an interactive PDF container in FileMaker is a web viewer, so our MBS WebView functions work with it!

I just tested in FileMaker 18 on macOS here.

Set Variable [ $r ; Value: MBS("WebView.Scrollbar.set"; "container"; 0; 0) ]

This works. And I named the layout object container to show the interactive container:

1 Like

Thank you for the clarification about the interactive PDF container! I didn't know that.

Then I am sorry to say that I can't get it to work. I did as you said, but the vertical position is always returned as 0 even though it is not. I also made a new database, included, with only a container field with the same result.

I guess I miss some vital piece of the puzzle or is doing something wrong, but I cant't figure it out and have tested with all I can think of. (The test is made with FileMaker 18 on Mac OS).

Script:

Layout:

Skärmavbild 2023-06-19 kl. 10.09.14

Skärmavbild 2023-06-19 kl. 09.55.47

Result:

Scroll PDF.fmp12.zip (464.1 KB)

Old plugin maybe?
I fixed this for 13.2, I think.

Now I got time to test, and you are right!
I was running 13.1.0.07 from March, and after updating the content is scrolled to the top.
(Only the content and not the scrollbar moves, but for me that is not a problem).

Many thanks!