open printing to pdf - does not work

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
aetaylorBUSBnWt
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 71
Joined: Thu Sep 20, 2012 5:11 pm

open printing to pdf - does not work

Post by aetaylorBUSBnWt » Wed Sep 21, 2022 5:58 pm

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

SWEdeAndy
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 118
Joined: Sat Aug 16, 2008 9:48 am
Location: Stockholm, Sweden
Contact:

Re: open printing to pdf - does not work

Post by SWEdeAndy » Wed Sep 21, 2022 6:43 pm

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.
Andreas Bergendal
Independent app and system developer
WhenInSpace: https://wheninspace.se

aetaylorBUSBnWt
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 71
Joined: Thu Sep 20, 2012 5:11 pm

Re: open printing to pdf - does not work

Post by aetaylorBUSBnWt » Wed Sep 21, 2022 7:21 pm

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.

Klaus
Posts: 13034
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: open printing to pdf - does not work

Post by Klaus » Wed Sep 21, 2022 9:34 pm

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

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3405
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Re: open printing to pdf - does not work

Post by mwieder » Fri Sep 23, 2022 3:43 am

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.

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”