我從NSTextview
保存PDF並在標題中放置徽標。我忽略了pageHeader
並且標誌出現了,但它被裁剪了。是否可以更改NSTextView的標題高度?
是否可以更改NSTextView
的標題高度?
謝謝!
部分代碼:
-(IBAction)impLaudo:(id)sender
{
NSPrintInfo *printInfo;
NSPrintInfo *sharedInfo;
NSPrintOperation *printOp;
NSMutableDictionary *printInfoDict;
NSMutableDictionary *sharedDict;
sharedInfo = [NSPrintInfo sharedPrintInfo];
sharedDict = [sharedInfo dictionary];
printInfoDict = [NSMutableDictionary dictionaryWithDictionary:sharedDict];
[printInfoDict setObject:NSPrintSaveJob forKey:NSPrintJobDisposition];
[printInfoDict setObject:[[dirLaudos stringByAppendingString:[estudo stringValue]] stringByAppendingString:@".pdf"] forKey:NSPrintSavePath];
printInfo = [[NSPrintInfo alloc] initWithDictionary: printInfoDict];
[printInfo setHorizontalPagination: NSClipPagination];
[printInfo setVerticalPagination: NSAutoPagination];
[printInfo setVerticallyCentered:NO];
[[printInfo dictionary] setValue:[NSNumber numberWithBool:YES] forKey:NSPrintHeaderAndFooter];
printOp = [NSPrintOperation printOperationWithView:textView printInfo:printInfo];
[printOp setShowsPrintPanel:NO];
[printOp runOperation];
}
@implementation MyTextView
- (NSAttributedString *)pageHeader
{
// Adicionando cabeçalho
NSAttributedString *theHeader = nil;
NSImage * pic = [[NSImage alloc] initWithContentsOfFile:[dirLayout stringByAppendingString:@"cabecalho.jpg"]];
NSTextAttachmentCell *attachmentCell = [[NSTextAttachmentCell alloc] initImageCell:pic];
NSTextAttachment *attachment = [[NSTextAttachment alloc] init];
[attachment setAttachmentCell: attachmentCell ];
theHeader = [NSAttributedString attributedStringWithAttachment: attachment];
return theHeader;
}
@end
請發佈您用於生成PDF的代碼。 – 2012-01-27 21:42:51