Printing to PDF - wants the card to be open

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
p0ntif
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 18
Joined: Fri Mar 15, 2013 4:41 pm

Printing to PDF - wants the card to be open

Post by p0ntif » Sun Jul 27, 2014 5:26 pm

I currently have a program running where I ask for a bunch of user input and then save it to a PDF.
However, since this is to be a mobile application that creates a full size printable PDF, I am using a substack of the appropriate A4 paper size and saving that.
Unfortunately it will not create a PDF unless that card is open. is there a way around this? Thanks in advance!

I have scripted a button for creating the PDF is as follows:

Code: Select all

  
On mouseUp
ask file "Save PDF as:" with "PDF.pdf"
   if it is empty then exit mouseUp
   open printing to PDF it
   print card 1 of stack "surveyss" into the printRectangle
   close printing
end mouseUp

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: Printing to PDF - wants the card to be open

Post by Mark » Sun Jul 27, 2014 10:20 pm

Hi,

You can't print a card or stack that isn't open, but you can print hidden stacks:

Code: Select all

on mouseUp
  ask file "Save PDF as:" with "PDF.pdf"
   if it is empty then exit mouseUp
   lock messages
   go inv cd 1 of stack "surveyss"
   unlock messages
   open printing to PDF it
   print card 1 of stack "surveyss" into the printRectangle
   close printing
   lock messages
   close stack "surveyss"
   unlock messages
end mouseUp
Kind regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

p0ntif
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 18
Joined: Fri Mar 15, 2013 4:41 pm

Re: Printing to PDF - wants the card to be open

Post by p0ntif » Sun Jul 27, 2014 11:04 pm

Excellent! thank you!

Post Reply