【发布时间】:2012-12-12 15:43:06
【问题描述】:
我有一个 NSDocument 后代,我想打印到单个页面 - 当页面宽于高时拉伸以适应并自动旋转。 渲染视图根据内容确定其边界。 rectForPage 只返回 [self bounds]; knowPageRange 设置 range.length = 1 和 range.location = 1 并返回 YES。 使用下面的代码完成打印。
一切正常,除了自动旋转。在打印面板中,我看到了正确形状的预览(宽于高,正确的尺寸等),但是当我打印时,页面是合适的,但是在纵向模式下,不必要地缩小图像。 如果我没有设置 printInfo.paperSize,它会自动旋转正常,但不会缩放,而是会剪切图像。有什么想法吗?
附加信息:打印面板中的“查看 PDF”在预览中显示页面确定。 从预览打印,然后在预览的打印面板中显示图像旋转以匹配纸张纵向方向(即:横向图像本身显示为旋转)。这与我在打印面板中显示未旋转的情况不同。然后从预览的打印面板打印会做正确的事情。
- (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;
}
【问题讨论】:
-
可能是您的打印机试图比您更聪明吗?当您“打印到 PDF”时会发生什么?它仍然以不正确的方向出现吗?