open printing to pdf does not generate a pdf file

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
trags3
Posts: 432
Joined: Wed Apr 09, 2014 1:58 am

open printing to pdf does not generate a pdf file

Post by trags3 » Mon May 25, 2015 2:42 am

I'm having trouble with the "open printing to pdf" statement
I have a 2 card stack.
The card I want to print is named "letter"
on the first card I have a button with the following code:

on mouseUp
put the longFilePath of me into tpath
set the itemDelimiter to slash
delete the last item of tpath
put "/documents" & "/" after tpath
set the defaultfolder to tpath

open printing to pdf "test.pdf"
print card "Letter"
close printing -- send group of cards to printer
end mouseUp

There is no file named "test.pdf" anywhere on my computer or when installed on my iPhone there either.

I am working on a Macbook air OS X version 10.10.3
LC 7.0.5 Build 10034
Xcode Version 6.3.2

I have run it in the iOS simulator in the IDE and saved as standalone for iPhone and for Windows. Nothing works.
What am I doing wrong?

Tom

Klaus
Posts: 14182
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: open printing to pdf does not generate a pdf file

Post by Klaus » Mon May 25, 2015 1:19 pm

Hi Tom,

a couple of things:
1. "longfilepath" and "shortfilepath" dont have any effect on the mobile platform, only desktop!

2. obviously you are creating an incorrect filepath for your PDF
Use -> specialfolderpath("documents") instead, that will definitively work!

3. No need to mess with the defaultfolder when you can have an absolute pathname:
...
put specialfolderpath("documents") & "/test.pdf" into tPDF
open printing to pdf tPDF
...

Hints for the future:
Check THE RESULT when something does not work as exspected!
That will be empty on success, but may contain a hint to the current problem if any!

Code: Select all

...
open printing to pdf "test.pdf"
if the result <> EMTPY then
  anser "Error!" & CR & the result
  exit to top
end if
...
Best

Klaus

trags3
Posts: 432
Joined: Wed Apr 09, 2014 1:58 am

Re: open printing to pdf does not generate a pdf file

Post by trags3 » Tue Jun 16, 2015 1:45 pm

Klaus,
Thanks for the help. I have been away from this project for a couple of weeks but now that I'm back I have made some progress.
My code to save a card as a PDF file is:

on mouseUp
put specialFolderPath("documents") & "/letter.pdf" into tfiletoprint
open printing to pdf tfiletoprint
print cd"letter"
close printing
If the result <> EMPTY then
answer "Error" & cr & the result
exit to top
end if
end mouseUp

If all of this is successful I go on to convert the file to a JSON format and upload it to my server. (a whole other topic :D )

When I run the stack on the Mac Book Air OSX ver 10.10.3 and LC 7.0.5 everything works swimmingly.
When I put it on my iPhone 4s the error trapping if statement returns :

"Error
Printing Failed"
Any ideas?

Tom

trags3
Posts: 432
Joined: Wed Apr 09, 2014 1:58 am

Re: open printing to pdf does not generate a pdf file

Post by trags3 » Tue Jun 16, 2015 5:44 pm

StandAlone settings Check box PDF Printing. Seems to fix the problem. :oops:

Tom

Klaus
Posts: 14182
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: open printing to pdf does not generate a pdf file

Post by Klaus » Tue Jun 16, 2015 6:03 pm

Sigh...



Your message contains 7 characters. The minimum number of characters you need to enter is 10.

Post Reply