我试图在我的OS X应用程序中实现打印,但存在一个问题,我无法解决,我希望也许你们中的一个人有了一个主意。更改页面方向不会缩放内容
在Safari中,您可以点击打印,打印面板将显示如何以纵向模式打印内容,并且如果您单击方向按钮,它会以横向模式显示内容。
注意的内容进行缩放定向的每一个变化。
如果我在我的应用程序中尝试相同的内容不会改变;其宽度在纵向和横向上保持不变。
NSPrintOperation或NSPrintInfo中是否有我可能忽略的设置?
更新 - 现在代码:
- (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:&printError];
[[printOperation printPanel] setOptions:[[printOperation printPanel] options] | NSPrintPanelShowsPageSetupAccessory];
[printOperation runOperation];
}
非常感谢您的帮助, 最良好的祝愿, UEM
包含您当前打印操作的代码。 NSPrintOperation或NSPrintInfo有很多设置。 – 2013-02-14 15:36:46
Thx看着它。我包含了代码。 – uem 2013-02-14 16:08:27