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
open printing to pdf does not generate a pdf file
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Re: open printing to pdf does not generate a pdf file
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!
Best
Klaus
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
...
Klaus
Re: open printing to pdf does not generate a pdf file
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
)
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
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

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
Re: open printing to pdf does not generate a pdf file
StandAlone settings Check box PDF Printing. Seems to fix the problem.
Tom

Tom
Re: open printing to pdf does not generate a pdf file
Sigh...
Your message contains 7 characters. The minimum number of characters you need to enter is 10.
Your message contains 7 characters. The minimum number of characters you need to enter is 10.