Printing part of a card to PDF

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
SheyMouse
Posts: 9
Joined: Sat Jan 17, 2015 1:06 am

Printing part of a card to PDF

Post by SheyMouse » Sat Jan 17, 2015 1:26 am

I have been tinkering with the create PDF lesson and have hit a snag. Instead of printing the entire card I want to print 3/4 of the card.
I cannot get the syntax right for specifying the are of the card I want to print to PDF and could do with a bit of help. Here is the code I am working with:

Code: Select all

on printInvoice
   set the visible of button "btnPrint" to false 
   put specialFolderPath("documents") & "/Invoice009.pdf" into tPDFPath
   -- Handle the default text of the myCompany field
   if the text of field "myCompany" is "Your company" then
      set the visible of field "myCompany" to false
   else
      set the visible of field "myCompany" to true
   end if
       
   open printing to pdf tPDFPath
   if the result is "Cancel" then
      exit printInvoice
   else
      print card "invoice" of this stack into 0,0,575,600
   end if
   
   close printing
   set the visible of button "btnPrint" to true
end printInvoice
I think my setting the area to print to PDF is set here:

Code: Select all

print card "invoice" of this stack into 0,0,575,600
I have tried a couple of options which have included adding "from 0,0,575,400" usually, but the debug says I need a "to" at the end. Even though there is a "print to" command further up.

Any help would be greatly appreciated.

MaxDangerMouse
Posts: 19
Joined: Wed Jan 26, 2011 7:04 am

Re: Printing part of a card to PDF

Post by MaxDangerMouse » Sat Jan 17, 2015 8:54 am

Hi SheyMouse

The printing stuff can be a bit tricky but is super useful once you get the hang of it. The "into" part details where the part of the card goes in the final pdf. What you're looking for is "from" and "to"... try this:

Code: Select all

print card "invoice" of this stack from 0,0 to 575,600 
Good luck
Max

SheyMouse
Posts: 9
Joined: Sat Jan 17, 2015 1:06 am

Re: Printing part of a card to PDF

Post by SheyMouse » Sun Jan 18, 2015 1:02 am

Thanks for the suggestion. Unfortunately the suggested code resulted in a blank page being printed to PDF. I tried a couple of variations including

Code: Select all

print card "invoice" of this stack from 0,0 to 575,600 into 0,0,575,800
Nothing has worked so far.

Any other suggestions?

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7389
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Printing part of a card to PDF

Post by jacque » Sun Jan 18, 2015 8:49 pm

This works for me:

Code: Select all

print this card from 0,0 to 575,600
I have never tried printing a card that isn't open. When the script runs, is the invoice card the current one? It shouldn't need to be, but that's the only thing I can think of offhand.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Post Reply