Page 1 of 1

open printing to pdf - does not work

Posted: Wed Sep 21, 2022 5:58 pm
by aetaylorBUSBnWt
Hi,

I have not gone to trouble of creating a standalone application, so as I understand it, Livecode (version 9.6.8 Build 15593) on a Mac has everything it needs for standard operation.

I have a card with buttons, labels, text fields on it.
One of the buttons is a "Print" button and it has an "on mouseUp" handler.

If I put the following code in, the card is printed on the printer:

open printing
print card 1;
close printing;

As expected.

However, nothing happens with the following code:

open printing to pdf "file:/Users/andrewtaylor/temp/myFile.pdf"
print card 1;
close printing;


Yet that is all that is needed to print to PDF according to the Dictionary and all documentation that I can find.
Either bug, or I am missing something fundamental.

The above simple code is nowhere near what I want to do - which is to present a dialog box so that the user can select various parameters as well as target either printer or PDF or Preview, but I can't even get the above to work.

Please Help!
Thanks,
Andrew

Re: open printing to pdf - does not work

Posted: Wed Sep 21, 2022 6:43 pm
by SWEdeAndy
aetaylorBUSBnWt wrote:
Wed Sep 21, 2022 5:58 pm
open printing to pdf "file:/Users/andrewtaylor/temp/myFile.pdf"
Remove "file:" and your code should work as expected.

Re: open printing to pdf - does not work

Posted: Wed Sep 21, 2022 7:21 pm
by aetaylorBUSBnWt
arrgh!!

The simplest things!

So for those who want some print code with a dialog box and the option for PDF too.

Code: Select all

//put this in whatever handler/function you want:

    answer printer  //get print options from user, including printing to a PDF
    
    if the result is "Cancel" then exit "your handler name"
    if printerOutput begins with "file:" then
        local tWhere;
        put the printerOutput into tWhere;
        delete char 1 to 5 in tWhere;
        open printing to pdf tWhere;
    else
        open printing;
    end if
    
    print card 1;  //replace this with whatever you want to print.
    
    close printing  //this causes the actual printing or PDF creation.

Re: open printing to pdf - does not work

Posted: Wed Sep 21, 2022 9:34 pm
by Klaus
Hi Andrew,

using cr AND ; to delimit commands is OVERKILL! :-D
The ; is used if you don't want a new line for the script.

These are identical:

Code: Select all

...
put the printerOutput into tWhere;delete char 1 to 5 of tWhere;open printing to pdf tWhere;
...

Code: Select all

...
put the printerOutput into tWhere
delete char 1 to 5 of tWhere
open printing to pdf tWhere
...
Best

Klaus

Re: open printing to pdf - does not work

Posted: Fri Sep 23, 2022 3:43 am
by mwieder
Yes, but since it doesn't hurt to put the semicolons there (I didn't know this before), it may be more comfortable for folks coming to xtalk from a different language environment where they're necessary to signify the end of every command statement.