Printing options from answer printer

Jan Schenkel janschenkel at yahoo.com
Tue Nov 11 02:59:02 EST 2008


--- Bill Vlahos <bvlahos at mac.com> wrote:
> Joe,
> 
> I can't get that to work. I must have the syntax
> wrong but I'm not  
> seeing how it is wrong.
> 
> Make a new mainstack and put the following script in
> a button.
> 
> on mouseUp
>     answer printer as sheet
>     if the result is not "Cancel" then print this
> card from topLeft to  
> rightBottom into 72,72,72,72
> end mouseUp
> 
> The script editor doesn't complain about anything
> until you run it.  
> The it generates the following error.
> execution error at line 8 (print: coordinate not a
> point) near  
> "topLeft", char 1
> 
> Bill
> 

Hi Bill,

Are you really trying to print everything into a
single pixel ? :-)

You need to give the topleft and bottomright
coordinates of the section of the card that you want
to print, as well as the rectangle on the paper onto
which it shouldbe printed.

So if you want to print the part of your card enclosed
by a rectangle graphic on your card - into the same
coordinates and size on the paper, you use:
##
on mouseUp
  answer printer as sheet
  if the result is "Cancel" then exit mouseUp
  put the topleft of graphic "PrintRect" into
theTopLeft
  put the bottomRight of graphic "PrintRect" into
theBottomRight
  put the rectangle of graphic "PrintRect" into
thePaperRect
  print this card from theTopLeft to theBottomRight
into thePaperRect
end mouseUp
##

Now, if you want the same rectangular area on your
card to fit into a completely different rectangle on
paper, you use:
##
on mouseUp
  answer printer as sheet
  if the result is "Cancel" then exit mouseUp
  put the topleft of graphic "PrintRect" into
theTopLeft
  put the bottomRight of graphic "PrintRect" into
theBottomRight
  put "30,100,400,700" into thePaperRect
  print this card from theTopLeft to theBottomRight
into thePaperRect
end mouseUp
##
And what happens is that Revolution will take the area
from your card and stretch or shrink it to fit the
area on the printer.

When you use this 'print into rect' approach,
Revolution ignores the 'printScale' property; so if
you want to 'print into rect' with scaling to ensure
that everything fits while preserving a relative size,
you'll need to tweak your paper rectangle a bit.

Continuing with the above example of a rectangular
area on your card, you would have something like:
(mind the line wrappings)
##
on mouseUp
   answer printer as sheet
   if the result is "Cancel" then exit mouseUp
   set the printerOutput to "preview"
   put the topleft of graphic "PrintRect" into
theTopLeft
   put the bottomRight of graphic "PrintRect" into
theBottomRight
   put "30,100,500,700" into thePaperRect
   -- now we calculate how we can save the relative
size
   put item 1 of theBottomRight - item 1 of theTopLeft
\
      into theOriginWidth
   put item 2 of theBottomRight - item 2 of theTopLeft
into \
      theOriginHeight
   put item 3 of thePaperRect - item 1 of thePaperRect
into \
      thePrintWidth
   put item 4 of thePaperRect - item 2 of thePaperRect
into \
      thePrintHeight
   put thePrintWidth / theOriginWidth into
theWidthRatio
   put thePrintHeight / theOriginHeight into
theHeightRatio
   if theWidthRatio > theHeightRatio then
      put round(theOriginWidth * theHeightRatio) into
thePrintWidth
   else if theWidthRatio < theHeightRatio then
      put round(theOriginHeight * theWidthRatio) into
thePrintHeight
   end if
   put item 1 of thePaperRect + thePrintWidth into \
      item 3 of thePaperRect
   put item 2 of thePaperRect + thePrintHeight into \
      item 4 of thePaperRect
   print this card from theTopLeft to theBottomRight
into thePaperRect
end mouseUp
##

HTH,

Jan Schenkel.

Quartam Reports & PDF Library for Revolution
<http://www.quartam.com>

=====
"As we grow older, we grow both wiser and more foolish at the same time."  (La Rochefoucauld)


      



More information about the use-livecode mailing list