Technical Note: How to Print the Stage

Updated: 4/19/04
Products: PrintOMatic Lite Xtra 1.6.5, PrintOMatic Lite MX Xtra, PrintOMatic Xtra 1.6.5, PrintOMatic MX Xtra
Platforms: all

The easiest way to print the Stage in either the Lite or the Full versions of PrintOMatic is simply to use the one-line printStage command.

However, for some people, printStage won’t do all you want. For example, you may want to print a portion of the stage instead of the whole thing, or you may want to customize the print job by hiding dialog boxes, etc.

Customizing Stage Printing

Below is a script that works ONLY with the Full version of PrintOMatic. This script duplicates in Lingo exactly what the printStage command does. It is a starting point for any customization you might want to do. Be careful of the 4 lines where drawStagePicture is called: you need to return these 4 lines to a single line of Lingo or you'll get a script error.
on myPrintStage
  
  set doc = new(xtra "PrintOMatic")
  if not objectP(doc) then
    -- no printer
    alert "There is no currently selected printer."
    exit
  end if
  
  -- setup print job
  setDocumentName doc, "My Stage Printout" -- or whatever
  setMargins doc, Rect(72,72,72,72) -- 1 inch margins
  
  set stageWidth = the width of the rect of the stage
  set stageHeight = the height of the rect of the stage
  
  -- set paper orientation
  if stageWidth > stageHeight then setLandscapeMode doc, TRUE
  
  set pageWidth = getPageWidth(doc)
  set pageHeight = getPageHeight(doc)
  
  -- figure out scaling of page
  set scaling = min(1.0,float(pageWidth)/float(stageWidth))
  set scaling = min(scaling,float(pageHeight)/float(stageHeight))
  
  set destWidth = integer(scaling*stageWidth)
  set destHeight = integer(scaling*stageHeight)
  
  -- figure top left starting point for a centered image
  set destLeft = (pageWidth-destWidth)/2
  set destTop = (pageHeight-destHeight)/2
  
  -- make a new page
  newPage doc
  
  -- grab the stage, put it on the page
  -- remove line breaks so the next line is ONE LINE!
  drawStagePicture doc, 
     Rect(destLeft,destTop,destLeft+destWidth,destTop+destHeight), 
     Rect(0,0,stageWidth, stageHeight), 
     FALSE
  
  -- un-comment the next line to hide the progress dialog
  -- setProgressLoc doc, Point(-1000,-1000)
  -- this command only works in the registered Xtra
  
  -- comment out the next line and the "end if" line to hide job setup
  if doJobSetup(doc) then
    print doc -- you can substitute print preview here, too!
  end if
  
  set doc = 0
  
end

A printFrom Replacement

The code below is a PrintOMatic-based replacement to Director's built-in printFrom command. Since printFrom doesn't work in Shockwave, this is the way to get the same functionality. It's also a good starting point for any customization you might want to do.

Note that this code only works in the FULL version of PrintOMatic, and not the Lite version.

This function is called myPrintFrom and accepts the same parameters (first frame, last frame, reduction) that printFrom does, as well as allowing you to set the document name as the last parameter.

Watch the line breaks when you copy and paste this code. The line that begins with drawStagePicture will need to have extra line-breaks removed for the code to compile.

on myPrintFrom firstFrame, lastFrame, reduction, documentName
  
  set doc = new(xtra "PrintOMatic")
  if not objectP(doc) then
    -- no printer
    alert "There is no currently selected printer."
    exit
  end if
  
  -- setup print job
  if stringP(documentName) then setDocumentName doc, documentName
  setMargins doc, Rect(72,72,72,72) -- 1 inch margins
  
  set stageWidth = the width of the rect of the stage
  set stageHeight = the height of the rect of the stage
  
  -- set paper orientation
  if stageWidth > stageHeight then setLandscapeMode doc, TRUE
  
  set pageWidth = getPageWidth(doc)
  set pageHeight = getPageHeight(doc)
  
  -- figure out scaling of page
  if integerP(reduction) then
    set scaling = float(reduction)/float(100)
  else
    -- auto scaling
    set scaling = min(1.0,float(pageWidth)/float(stageWidth))
    set scaling = min(scaling,float(pageHeight)/float(stageHeight))
  end if
  
  set destWidth = integer(scaling*stageWidth)
  set destHeight = integer(scaling*stageHeight)
  
  -- figure top left starting point for a centered image
  set destLeft = (pageWidth-destWidth)/2
  set destTop = (pageHeight-destHeight)/2
  
  -- set valid last frame
  if not integerP(lastFrame) then set lastFrame = firstFrame
  
  set originalFrame = the frame
  repeat with theFrame = firstFrame to lastFrame
    go to frame theFrame
    -- make a new page
    newPage doc

    -- grab the stage, put it on the page
    -- remove line breaks so the next line is ONE LINE
    drawStagePicture doc,
        Rect(destLeft,destTop,destLeft+destWidth,destTop+destHeight),
        Rect(0,0,stageWidth, stageHeight), FALSE

  end repeat
  go to frame originalFrame
  
  -- un-comment the next line to hide the progress dialog
  -- setProgressLoc doc, Point(-1000,-1000)
  -- (the above command only works in the registered Xtra)
  
  if the controlDown then
    -- hold down the control key for a print preview
    printPreview doc
  else
    -- comment out the next line and the "end if" line to hide job setup
    if doJobSetup(doc) then
      print doc -- you can substitute print preview here, too!
    end if
  end if
  
  set doc = 0
  
end

To view this and other technical notes on-line, visit http://www.printomatic.com/tech.cfm.