Open and download PDF from app

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Ricardo A
Posts: 15
Joined: Tue Jun 14, 2011 1:42 pm

Open and download PDF from app

Post by Ricardo A » Mon Nov 07, 2011 8:07 pm

I am new in Livecode. I want to create a simple application for iPad. Basically, I will show a list of PDF files and then the selected file will open on a RevWeb, I imagine. One file per time, one page for each PDF. The user can go back to the list to choice another file and so on. Another requisite is about the PDFs upgrade. They need to be upgraded or changed on-line. I don't know how to do this or if it is possible. I think I will need to work with a kind of database or xml to check the news PDF and download then. Somebody can tell me if LiveCode is the right tool? The iPad iOS allow this upgrade directly from a web repository?

FireWorx
Posts: 362
Joined: Wed Sep 07, 2011 9:39 pm

Re: Open and download PDF from app

Post by FireWorx » Fri Nov 11, 2011 8:28 am

Hi,
I have just constructed an app that does exactly what you want to do. My app contains about 200 PDF'S that are located in several folders. You will need to use the "Copy Files" tab in the standalone preferences to select these folders and copy them into the "engine" folder. They will then be accessible to be loaded via code into a browser from this folder, be scaled to fit your browser windows width, then once the PDF is loaded zooming and scrolling is done with the touch screen.

If you want your files to be updated through iTunes you will need to move the folders containing the PDF's via code to the "documents" folder. You can access them and load them into the browser from there as well. Live Code 5.0 with IOS 5.0 is much faster at rendering the pages then Live code 4.6 was and you can zoom ALL the way in which you couldn't do in 4.6.

The code can get tricky and working with the documents and engine folder within the AP is kinda like working in the dark because you can't just open the folder and look inside it without building some tools to help you do it from within the tester but I have a few examples I can send you if your up for the challenge. email me at kitethewind@gmail.com

Dave
PS I have seen a script and tried it out that gets a file from a web server and over writes an existing PDF file located in the documents folder.

Ricardo A
Posts: 15
Joined: Tue Jun 14, 2011 1:42 pm

Re: Open and download PDF from app

Post by Ricardo A » Fri Nov 11, 2011 8:05 pm

Dave, I am using LiveCode 5, IOS 5 and XCode 4.2. I want to start from the first step. I managed to copy files from "engine" to "documents". I could write and read text files on engine. But something strange is happening. It's simple. The PDF that exists on engine I can not open in revBrowser. I tried the MobGUI browser without sucssess. A simple locally html is not open. I think I'm missing something simple. Could you send me a livecode sample to open a PDF locally in iPad? This is the first step because I will need to build a app to control about 1000 PDFs with database and show them like you did in your APP, including update with iTunes. Thanks very much.

Jellicle
Posts: 453
Joined: Thu Feb 24, 2011 11:07 am

Re: Open and download PDF from app

Post by Jellicle » Sat Nov 12, 2011 4:45 am

Show us your code...

Gerry
14" MacBook Pro
Former LiveCode developer.
Now recovering.

Jellicle
Posts: 453
Joined: Thu Feb 24, 2011 11:07 am

Re: Open and download PDF from app

Post by Jellicle » Sat Nov 12, 2011 12:14 pm

The code can get tricky and working with the documents and engine folder within the AP is kinda like working in the dark because you can't just open the folder and look inside it without building some tools
The simulator's file structure is available to you. With it running do a search for "iPhone simulator" in the Finder :). You can open files on the simulator and copy files to and from its folders.

Gerry
14" MacBook Pro
Former LiveCode developer.
Now recovering.

CALL-151
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 206
Joined: Wed Oct 20, 2010 11:00 am

Re: Open and download PDF from app

Post by CALL-151 » Sat Nov 12, 2011 9:30 pm

Gerry,

Can you elaborate? With the iOS simulator running my app, I am unable to find files that I know my app has created, or the related folders (engine, cache, etc) by searching via Finder (or Spotlight). I also looked inside the iOS Simulator.app package with no luck.

gpb01
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 281
Joined: Sat Jun 04, 2011 5:41 pm

Re: Open and download PDF from app

Post by gpb01 » Sat Nov 12, 2011 10:39 pm

CALL-151 wrote:Gerry,
Can you elaborate? With the iOS simulator running my app, I am unable to find files that I know my app has created, or the related folders (engine, cache, etc) by searching via Finder (or Spotlight). I also looked inside the iOS Simulator.app package with no luck.
Hi,
when you run the simulator, the app you're running is into :

~/Library/Application Support/iPhone Simulator/4.3.2/Applications/unique_name_folder_for_your_app

... change the 4.3.2 with the version of the simulator you're using (3.2, 4.0.2, 4.1, 4.3,4.3.2, 5.0)

Hope this help :)

Guglielmo

Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am

Re: Open and download PDF from app

Post by Dixie » Sat Nov 12, 2011 11:15 pm

Ricardo...

I have attached at stack that contains three small .pdf files... You can choose which of the three you wish to load into the UIwebView and then it will display. These .pdf's are loaded into the 'engine' folder... this is not a good place to keep them, the 'documents' folder is the place if you wish to be able to change them out whenever you wish, or download them from a server... the choice is yours.

There are two cards in the stack, look at the card scripts of both of them...

hope it helps

Dixie
Attachments
openpdf.zip
(40.81 KiB) Downloaded 388 times

Ricardo A
Posts: 15
Joined: Tue Jun 14, 2011 1:42 pm

Re: Open and download PDF from app

Post by Ricardo A » Sun Nov 13, 2011 1:48 am

I ll work and try on real device with this files. Thanks so much.

CALL-151
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 206
Joined: Wed Oct 20, 2010 11:00 am

Re: Open and download PDF from app

Post by CALL-151 » Sun Nov 13, 2011 10:41 pm

gpb01 wrote: when you run the simulator, the app you're running is into :

~/Library/Application Support/iPhone Simulator/4.3.2/Applications/unique_name_folder_for_your_app

... change the 4.3.2 with the version of the simulator you're using (3.2, 4.0.2, 4.1, 4.3,4.3.2, 5.0)

Hope this help :)

Guglielmo
Thanks Guglielmo, found it. The ~/Library folder is hidden in Lion.

gpb01
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 281
Joined: Sat Jun 04, 2011 5:41 pm

Re: Open and download PDF from app

Post by gpb01 » Mon Nov 14, 2011 7:09 pm

CALL-151 wrote: Thanks Guglielmo, found it. The ~/Library folder is hidden in Lion.
:)
... I'm still on Snow Leopard :D

Guglielmo

Ricardo A
Posts: 15
Joined: Tue Jun 14, 2011 1:42 pm

Re: Open and download PDF from app

Post by Ricardo A » Wed Nov 16, 2011 9:00 pm

Hi Dixie, it worked well. Thanks for the sample. And how do I update the PDFs from the server? Some suggestion? Thanks again.

Jellicle
Posts: 453
Joined: Thu Feb 24, 2011 11:07 am

Re: Open and download PDF from app

Post by Jellicle » Wed Nov 16, 2011 10:03 pm

Ricardo A wrote:Hi Dixie, it worked well. Thanks for the sample. And how do I update the PDFs from the server? Some suggestion? Thanks again.

My example stack at http://forums.runrev.com/download/file.php?id=1034 shows how to download a stack file from a server. It can download PDFs instead with a little modification.

Gerry
14" MacBook Pro
Former LiveCode developer.
Now recovering.

Ricardo A
Posts: 15
Joined: Tue Jun 14, 2011 1:42 pm

Re: Open and download PDF from app

Post by Ricardo A » Thu Nov 17, 2011 2:57 pm

You and others will know when the APP will finish on begining of 2012. i'll put on thanks. God willing. Thanks again.

Post Reply