Page 1 of 1

Print to PDF

Posted: Tue Apr 24, 2012 7:43 pm
by bsouthuk
Hi

I wonder if someone can help me.

I am trying to print to pdf using my iPad. My app works perfectly on my iPad apart from printing to pdf. I am trying the following code:

Code: Select all

on mouseUp
   open printing to PDF "myPDF.pdf"
print this card
close printing
launch document "myPDF.pdf"
end mouseUp
this works fine when trying on the MAC. But not when testing directly on my iPad. When i click the button with the script, nothing happens, no pdf is launched, nothing.

Is there something I am doing wrong here?

Thanks

Daniel

Re: Print to PDF

Posted: Tue Apr 24, 2012 10:16 pm
by JosepM
Hi,

Check this post...

http://forums.runrev.com/viewtopic.php? ... pdf#p54123

Salut,
Josep M

Re: Print to PDF

Posted: Tue Apr 24, 2012 10:33 pm
by bsouthuk
Hi

I already checked this post and tried all the different code but the PDF never opens on my iPad. I'm not even sure if the PDF actually saves to the iPad. And if it does save then where?

Very confused on this one!

Re: Print to PDF

Posted: Wed Apr 25, 2012 12:27 pm
by Klaus
Hi Daniel,
And if it does save then where?
well, you are the developer and if you can answer this, who can?
Come on!

And this is exactly is the problem:
"myPDF.pdf" is a valid filename on the desktop/IDE.
This will be in the current "defautlfolder", whereever that may be!
It is up to you to know this!

But "the defaultfolder" on iOS is obviopusly the folder inside of the
application package***, where you do NOT have write permissions!
*** specialfolderpath("engine")

So at this point the script silently fails and does not continue!

If you pass a VALID filename to the print command, it sure will work!
...
## We are allowed to write to the users docs folder!
put specialfolderpath("documents") & "/yourPDF.pdf" into tPdfFile
open printing to PDF tPdfFile
print this card
close printing
launch document tPdfFile
...

Best

Klaus

Re: Print to PDF

Posted: Wed Apr 25, 2012 1:42 pm
by bsouthuk
Thank you for your email Klaus but I have already tried this code and still the PDF does not open when using my iPad. Nothing happens when i click on the button that obtains the code.

I have checked the box in the standalone settings for print to pdf but still nothing. I presume that the pdf will open on top of the app that is running? And if you close the pdf that opens then the app will then be displayed?

Re: Print to PDF

Posted: Wed Apr 25, 2012 1:53 pm
by Klaus
Hi Daniel,

hmmm...?

Please add this right after the print command to check, if the PDF has really been created:
...
put specialfolderpath("documents") & "/yourPDF.pdf" into tPdfFile
open printing to PDF tPdfFile
print this card
close printing
answer (thre is a file tPFDFile)
## Should be true on success
## if this displays in fact TRUE then you could try to add a little wait
## 10 = 10 ticks = 60 ticks = 1 second
wait 10
launch document tPdfFile
...
And yes the app that opens the PDF should open on top of your app,
which should appear again after the user closed the PDF.
But since I do not own an iOS license I am not sure.


Best

Klaus

Re: Print to PDF

Posted: Wed Apr 25, 2012 2:05 pm
by bsouthuk
Hi Klaus

I tested this in my MAC, the message that appears is true and the pdf opens straight away. However, when testing the IPAD, the message also appears as true but no pdf is launched.

In the Sandbox, documents folder in Xcode on the mac, the pdf file is displayed. Though I still have no idea in how to find the pdf file on the iPad itself as I cannot find a Documents folder on it!

Re: Print to PDF

Posted: Wed Apr 25, 2012 2:37 pm
by Klaus
Hi daneil,

sorry, no idea..

But you could add another answer which may give you a hint:
...
launch document tPdfFile
answer the result
## should not be empty, if the PDF will not launch
...

Best

Klaus

Re: Print to PDF

Posted: Wed Apr 25, 2012 3:19 pm
by bsouthuk
I get:

/var/mobile/Applications/C36456456456456456546/Documents/yourPDF.pdf

I have tested my iPad to see if it can open pdfs from emails which is can. I cannot understand why the pdfs are not being launched as I have done everything that is required!

Re: Print to PDF

Posted: Wed Apr 25, 2012 3:36 pm
by Klaus
"the result" returns the FILEPATH? :shock:
Sorry, no more ideas...

Re: Print to PDF

Posted: Tue May 01, 2012 1:14 pm
by bsouthuk
Thanks for your help Klaus

I have been told by the guys at LC that the Launch Document command does not work for mobile deployment. The following external I have been told should help: http://mergext.com/

Or displaying the pdf within a browser object.

Re: Print to PDF

Posted: Tue May 01, 2012 1:42 pm
by Klaus
bsouthuk wrote:I have been told by the guys at LC that the Launch Document command does not work for mobile deployment.
Ah, did not know this, thanks for the info!

Re: Print to PDF

Posted: Tue May 01, 2012 9:31 pm
by monte
Theres a few advantages to using mergDoc for displaying the PDF. One line of code and you get the standard modal preview and from there your user can print or send to another app without any extra code from you. You can still get mergExt + MobGUI for half price using the MERGUI code on the runrev store. The offer ends if a few days.

Cheers

Monte

Re: Print to PDF

Posted: Thu May 03, 2012 10:22 pm
by CALL-151
Bsouthuk,

Just to make sure you're clear about what your issue was, your code was printing to pdf, you just couldn't find it because of the way iOS sandboxing restricts access. The fact that other apps on your iOS device can open PDFs is irrelevant. The iOS release notes are a must in order to understand how to write to and read from various locations within your app's sandbox and the significant differences between those different locations. In addition, the dictionary is the most reliable guide to what works and what doesn't on iOS.

If you want to code your own PDF viewer inside your app, read about iphoneControlCreate "browser", but if you're serious about iOS app development with LC, I'd highly recommend grabbing MobGUI and the MergExt externals while they're on sale.