Path: utzoo!utgpu!watmath!clyde!att!ucbvax!decwrl!thundr.dec.com!minow From: minow@thundr.dec.com (Repent! Godot is coming soon! Repent!) Newsgroups: comp.sys.mac.programmer Subject: re: Landscape printing? Message-ID: <8901092122.AA04439@decwrl.dec.com> Date: 10 Jan 89 00:08:00 GMT Organization: Digital Equipment Corporation Lines: 64 I recently asked how to manage landscape printing -- my program would put the page setup dialog on the screen, but the data would always be printed in portrait format. It turned out that I was reinitializing PrDefault() each time my program opened the printer. Here's a sketch of a better way to do things (variables are missing): THPrint print_handle = NIL; void do_page_setup() /* From the Page Setup menu option */ { open_printer(); if (PrStlDialog(print_handle)) ; PrClose(); } void print_the_document() /* From the Print menu option */ { open_printer(); if (PrJobDialog(print_handle)) { GetPort(&save_port); number_of_copies = how_many_copies(); for (copy = 1; copy <= number_of_copies; copy++) { print_document(); /* You supply this! */ if ((**print_handle).prJob.bJDocLoop == bSpoolLoop && PrError() == noErr) { PrPicFile(print_handle, NIL, NIL, NIL, &status); } SetPort(save_port); } PrClose(); } int how_many_copies() { if ((**print_handle).prJob.bJDocLoop == bDraftLoop) return ((**print_handle).PrJob.iCopies); else { return (1); } } void open_printer() /* Initializes print_handle, too */ { PrOpen(); if (PrError() != noErr) { fatal_error("\pCannot open printer"); ExitToShell(); } if (print_handle == NIL) { print_handle = (TPrint **) NewHandle(sizeof (TPrint)); PrintDefault(print_handle); } PrValidate(print_handle); } Thanks to Larry Rosenstein and Walter Smith of Apple for suggestions. Martin Minow minow%thundr.dec@decwrl.dec.com