我試圖在我的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