Note that there are some explanatory texts on larger screens.

plurals
  1. POChanging page orientation does not scale contents
    text
    copied!<p>I'm trying to implement printing in my OS X app but there's a problem that I can't solve and I hope that maybe one of you has got an idea.</p> <p>In Safari for instance you can hit print and the print panel will show you how the the contents will be printed in portrait mode and if you click on the orientation button it will show you the contents in landscape mode.</p> <p><img src="https://i.stack.imgur.com/NLun8.png" alt="Portrait mode"></p> <p><img src="https://i.stack.imgur.com/gLgAY.png" alt="Landscape mode"></p> <p>Notice that the contents is scaled with every change of the orientation.</p> <p>If I try the same in my app the contents does not change; its width stays the same in portrait and in landscape.</p> <p>Is there any setting in NSPrintOperation or NSPrintInfo that I might have overlooked?</p> <p><strong>Update</strong> - now with code:</p> <pre><code>- (NSPrintOperation *)printOperationWithSettings:(NSDictionary *)printSettings error:(NSError **)outError { NSPrintInfo *pInfo = [NSPrintInfo sharedPrintInfo]; [pInfo setLeftMargin:32]; [pInfo setRightMargin:32]; [pInfo setTopMargin:64]; [pInfo setBottomMargin:64]; [pInfo setHorizontalPagination:NSFitPagination]; [pInfo setVerticallyCentered:NO]; [[pInfo dictionary] setValue:[NSNumber numberWithBool:YES] forKey:NSPrintHeaderAndFooter]; [[pInfo dictionary] addEntriesFromDictionary:printSettings]; PrintTextView *printView = [[[PrintTextView alloc] initWithFrame:[pInfo imageablePageBounds]] autorelease]; printView.printJobTitle = @"Printed"; MSTablePrint *tPrint = [[[MSTablePrint alloc] init] autorelease]; NSMutableArray *itemArray = [[[NSMutableArray alloc] init] autorelease]; /* Objects are added to "itemArray" */ NSAttributedString *atString = [tPrint attributedStringFromItems:itemArray]; [[printView textStorage] setAttributedString:atString]; NSPrintOperation *printOp = [NSPrintOperation printOperationWithView:printView printInfo:pInfo]; return printOp; } - (IBAction)print:(id)sender { NSError *printError = nil; NSPrintOperation *printOperation = [self printOperationWithSettings:nil error:&amp;printError]; [[printOperation printPanel] setOptions:[[printOperation printPanel] options] | NSPrintPanelShowsPageSetupAccessory]; [printOperation runOperation]; } </code></pre> <p>Thanks very much for your help, best wishes, uem</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload