Page 1 of 1

Printing part of a card to PDF

Posted: Sat Jan 17, 2015 1:26 am
by SheyMouse
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.

Re: Printing part of a card to PDF

Posted: Sat Jan 17, 2015 8:54 am
by MaxDangerMouse
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

Re: Printing part of a card to PDF

Posted: Sun Jan 18, 2015 1:02 am
by SheyMouse
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?

Re: Printing part of a card to PDF

Posted: Sun Jan 18, 2015 8:49 pm
by jacque
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.