Robert, Thanks for the great Christmas present! I relocated PMSetOrientation ahead of my route _toPrinter and everything works well. This code could probably be useful by others as well. I am using this to enable users and my program to predefine the print orientation of invoices, purchase orders and other reports. The eliminates unnecessary user time spent changing the page setup and makes sure that various forms are printed correctly. Doug > On Monday, December 23, 2002, at 10:14 PM, Robert Purves wrote: > > >> On Tuesday, December 24, 2002, at 01:23 PM, Douglas Stemen wrote: >> >> This is really weird. PMSetOrientation only works once, for the first >> print job, while the program is running. After the first print job >> PMSetOrientation no longer sets printing to landscape mode. > > Fortunately that's not really true. You do have to be careful where > you call PMSetOrientation. > > It will fail with an error if called immediately after close lprint > (which disposes the Carbon Print Manager structures gFBPrintSession, > gFBPageFormat, gFBPrintSettings). When testing, you should always > check the error code from PMSetOrientation. > > It will silently fail if called after PMSessionBeginDocument. Apple > says: "If you call the function PMSetOrientation after your > application calls PMSessionBeginDocument for the print job, the > changes are ignored for the current print job." > PMSessionBeginDocument is called (if I follow the runtime correctly) > by route _toPrinter. > > Here's another demo, in which 2 print jobs are run, both getting your > required landscape orientation. > > > '--------------- > '~'A > ' CPU : Carbon > '~'B > _kPMPortrait = 1 > _kPMLandscape = 2 > toolbox fn PMSetOrientation( PMPageFormat pageFormat, ¬ > UInt16 orientation, Boolean lock ) = OSStatus > > dim as OSStatus err > dim as long j > for j = 1 to 2 > def lprint > long if prCancel == _false > // set landscape orientation > err = fn PMSetOrientation( gFBPageFormat, _kPMLandscape, _false ) > if err then stop "PMSetOrientation error " + str$( err ) > route _toPrinter > print "Test" j > route _toScreen > close lprint > end if > next > > do > HandleEvents > until 0