Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to auto rotate page when printing NSDocument via NSView?
    text
    copied!<p>I have a NSDocument descendant that I would like to print to a single page - stretched to fit and auto rotated when the page is wider than high. The rendering view determines its bounds based on the content. rectForPage simply returns [self bounds]; knowsPageRange sets range.length = 1 and range.location = 1 and returns YES. Printing is done using the code below.</p> <p>Everything works, execpt the auto -rotation. In the Print Panel I see the preview in the correct shape (wider than high, the correct size etc.), However when I then print, the page is fitted, but in portrait mode, unnecessary scaling down the image. If I do not set printInfo.paperSize, it auto rotates OK, but does not scale, instead it clips the image. Any idea?</p> <p>Additional info: The "View PDF" from the print panel shows the page OK in Preview. Printing from Preview, then shows the image <em>rotated</em> in Preview's Print Panel to match the paper potrait orientation (that is: the landscape image itself appears rotated). This is different from my case where it shows unrotated in the print panel. Printing from Preview's Print Panel then does the correct thing.</p> <pre><code>- (NSPrintOperation *)printOperationWithSettings:(NSDictionary *)printSettings error:(NSError **)outError { MindMapRenderingView *renderingView = [[MindMapRenderingView alloc] initWithMindMap:_mindMap printJobTitle:[_mindMap singleLineTitle]]; NSSize pageSize = [renderingView bounds].size; NSPrintOperation *printOperation = [NSPrintOperation printOperationWithView:renderingView printInfo:[self printInfo]]; [renderingView release]; NSPrintInfo* printInfo = [printOperation printInfo]; [[printInfo dictionary] addEntriesFromDictionary:printSettings]; if (isLandscape) [printInfo setOrientation:NSLandscapeOrientation]; else [printInfo setOrientation:NSPortraitOrientation]; [printInfo setPaperSize:pageSize]; [printInfo setHorizontalPagination:NSFitPagination]; [printInfo setVerticalPagination:NSFitPagination]; return printOperation; } </code></pre>
 

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