I have created several procedures that manipulate data and I use the “PrinttoPDF” to automatically print. Instead I would like 3 options. 1) Preview the document without printing 2) Create a PDF of the form and save to desktop without printing 3) Print as usual without any dialog.
In short, I would like to select one of the three options.
Any ideas would be appreciated.
Option 1: Use the printpreview statement; this creates a PDF and displays in in Preview.app. Or you use the menu command File > Preview.
Option 2: Use the printtopdf statement with a path e.g.
Option 3: Use the print “” statement or the printtodf statement with the printer option.
You could use Alertsheet to display the choices, like this:
Alertsheet "What do you want to do? ","Buttons","Print,Print to PDF,Preview,Cancel" If info("dialogtrigger")="Preview" Openform "your form name" Printpreview elseif info("dialogtrigger")="Print to PDF" PrinttoPDF "~/Desktop/My report.pdf","Form","Your form name" elseif info("dialogtrigger")="Print" PrinttoPDF "","Printer","","Form","Your form name" else nsnotify "You cancelled" return endif
Thank you so much KJM and CooperT for the quick response. I will try these options.
Are you sure about the Alertsheet line?
I am getting a error when checking saying it does not recognize Buttons. Then it has an opening quote at Print but no closing quote. Thanks for any help.
I am sure that you can specify Buttons this way. I tested this code before I put it in my post. When you specify Buttons as an option for Alertsheet, you quote the whole list of buttons, separated by commas. You should also be sure not to insert spaces around the commas. Everything between the commas is part of the button name, including a space if you insert one. If you post the actual code you are using, someone may spot an error. And you can check the Help Page for Alertsheet, which has the details on all the available options.
The forum will sometimes not show the entire line of posted code. I wonder if that has created some confusion. The entire line is shown here.
If the code is wider than the window, as it is in this example, a horizontal scroll bar will appear. In that case, the text off to the right doesn’t appear unless you scroll to the right. But the text isn’t missing, you just have to scroll. Or, if you select the text and copy, you’ll get all of it.
Thanks for all the help.
The Alertsheet thing is great with the buttons.
I do have a question though. After selecting the preview button the form results shows up just fine in Adobe Acrobat. The problem is after viewing it how can I dismiss the preview, remove all summaries, and get back to the Data Entry form? I can’t put a button on the preview page in Acrobat.
I don’t the state of your selection or summaries, but you could add statements after the PrintPreview statement:
closewindow //this closes the window you opened two lines earlier removeallsummaries //removes all summary records openform "Your Data Entry Form"
You will still see the preview in Acrobat, but when you close that, you should see “Your Data Entry Form” although it may not be the top window.
That did the trick. The only thing I added was “selectall” because I was working with a subset of records. Thanks again for all your help.