iOS Question (SOLVED) I Created a pdf - now how do I open it.

MrKim

Well-Known Member
Licensed User
Longtime User
Solution: https://www.b4x.com/android/forum/threads/open-local-files-with-external-apps.51941/#content

Using Erel's very helpful tutorial I was able to convert my Android .pdf creator code to ios in about half an hour.

Now I have spent 4 hours trying to figure out how to make it available so I can open it.

The goal is to make it easy for the user to create the pdf, open it, and print it if that option is available.
Installing Acrobat reader as the viewer/printer source is fine with me. I installed it hoping it would find my file but of course, did not.

I read this https://www.b4x.com/android/forum/threads/files-and-folders.46137/#content
I inserted this line:
B4X:
#PlistExtra: <key>UIFileSharingEnabled</key><true/>
in my app but no luck. I cannot find my file in iTunes.
I ran the sample app in the link above and it works as advertised, but it does not show up in the iTunes store anywhere that I can see. (I searched for 1.txt)

I know the file is there.
After creating it I run this code:
B4X:
        If File.Exists(File.DirDocuments, "Test1.pdf") Then
            Log(File.DirDocuments)
            Log("Exists")
            Log(File.Size(File.DirDocuments, "Test1.pdf"))
            Log(DateTime.Date(File.LastModified(File.DirDocuments, "Test1.pdf")) & " : " & DateTime.Time(File.LastModified(File.DirDocuments, "Test1.pdf")))
        End If
and get this result:
B4X:
/var/mobile/Containers/Data/Application/B06A62FE-40E7-403E-B0A4-4AC15863DB6C/Documents/
Exists
184975
09/12/2020 : 13:59:44

Also tried xui.DefaultFolder

I tried Both Debug mode and Release.
Does it have to be in the app store to work?

Any help and information is greatly appreciated.
 
Last edited:

Waldemar Lima

Well-Known Member
Licensed User
That is the example I used to create the file. I guess I wasn't clear. I need to make the file available externally - so it can be opened in other apps.
 
Upvote 0

MrKim

Well-Known Member
Licensed User
Longtime User
Classic understanding of shared file is accessable from any device, in any OS. Why not to use eMail or not to put on own website ?
It adds steps. Extra steps require training. KISS definitely applies here.
The file is created from a database. The user needs to print it. Some users will want to edit it first. I have no control over what resources they have for printing, editing, etc. and I don't want to.
I will be providing probably 3 options. Ready to print PDF (my first and current concern), CSV, and plain text.
The idea is - create the file, give the user the filename, and let them take it from there. They can print it, edit it on there phone email it to their home computer for editing/printing, or get it by attaching the phone to their computer. I don't care. I just want to create a file and make it available to the user.
Jeez, it shouldn't be this hard. This was not a problem with Android.
Yes, unless I am mistaken, I could create the file, attach it to an email, and then the user could send it to themselves and then open it? That is just dumb.
Put it on my web site and then give them a link so they have to copy the link in to some other program? Equally dumb. Also,I then have to police my web site to get rid of old files. I like minimal maintenance.

I will give Waldemar Lima's link a try when I get a moment. That looks like it might work.
 
Upvote 0
Top