PDF's - Mobile

Viewing PDFs and Other Documents (spreadsheets, word processing, etc)

Many school documents and information are already in PDF's or other types of documents. The documents can be opened either in or out side of your app. We will look at both ways of doing this.

1. Launching a PDF inside of your program - (for Mobile Platforms)
(using a browser window)
If you want to keep everything inside your app (without going to another program), you can use a  browser window (revBrowser object). 

First you need to initialize the revBrowser. It only has to be done once. (Just as you open up a normal browser (IE, FireFox, Safari, Chrome) and just use that one, to visit different sites). Most of the time, we put this in the openCard handler that runs when you first open the card.

a. Initializing the Browser Object (Window)

First create an image area for the browser window using the "image Area Tool" and size it on your card. Name it "browser image"

-----------Put this code on the Card Script --------------------------------

        global myBrowser

        on openCard
                browserOpen
        end openCard

        on browserOpen
                 put revBrowserOpen(the windowid of this stack,"") into myBrowser
                revBrowserSet myBrowser"showborder","true"
                revBrowserSet myBrowser"visible","true"
                revBrowserSet myBrowser"rect",rect of image "browser image"
        end browserOpen

        on browserClose
                revBrowserClose myBrowser
                put empty into myBrowser
        end browserClose

-----------Put this code on the Card Script --------------------------------

note: You might want to refer to the lesson - How Do I Display a PDF


b. Showing the PDF

Put the code below on a button on your card. This will open the pdf in the "browser image" field that you created above

        global myBrowser
        on mouseUp
              revBrowserSet myBrowser , "url""/User/Admin/Documents/Bell Schedule.pdf"
        end mouseUp


Notes: 

1. if a filename has a space in the document name then revBrowser will silently fail. Replacing space with %20 cures this.

replace " " with "%20" in myUrl

2. You can do a lot more with revBrowser that we have discussed in this lesson, for more information have a look at the revBrowser functions and commands in the Dictionary.

For more examples of what you can do with revBrowser there is a Browser Sampler stack in the Resources/Examples folder of your Rev distribution.

You might also find the Explore LiveCode: The Internet tutorial interesting

3. If you are developing a program that is running on a mobile device, then have a look at this lesson:  http://lessons.runrev.com/s/lessons/m/4069/l/22836

old: revBrowser is only supported on desktop platforms. You can view PDF files from the Internet on iOS using Browser Control. Check out this lesson on how to do it: http://lessons.runrev.com/s/lessons/m/4069/l/22836-How-do-I-use-the-Browser-Control-



 

Comments