Looking for a sample for print header & footer
Looking for a sample for print header & footer
- Subject: Looking for a sample for print header & footer
- From: Hebin Wei <email@hidden>
- Date: Wed, 20 Oct 2004 17:10:59 -0400
Hi guys
I am working on a small Document based application to implement a simple
text editor. I need to print out a header & footer along with the document.
I follow the instruction in the following link, but start point of the print
out always wrong, event I set it to {0,0}.
http://developer.apple.com/documentation/Cocoa/Conceptual/Printing/Tasks/Pag
inatingViews.html
Could anyone give me a small sample showing how to add header and footer in
cocoa?
Thanks
Following is my code:
============================
- (void)drawPageBorderWithSize:(NSSize)borderSize
{
[self lockFocus];
NSPrintInfo *pInfo = [[NSPrintOperation currentOperation] printInfo];
// We need to expend the frame so that we can print on the margin.
NSRect theRect;
NSRect oldFrame = [self frame];
theRect.size.width=borderSize.width;
theRect.size.height=borderSize.height;
theRect.origin.x=0;
theRect.origin.y=0;
[self setFrame:theRect];
theRect.size.width=oldFrame.size.width;
theRect.size.height=36; // this should be the height of the header
theRect.origin.x=0;// should be [pInfo leftMargin];
theRect.origin.y=0;// What is this?
NSString *theString = @"This is header.";
NSMutableAttributedString *theTitle = [[[NSMutableAttributedString
alloc] initWithString:theString] autorelease];
// [theTitle addAttribute:NSFontAttributeName value:[NSFont
fontWithName:@"Arial Bold" size:16.0] range:NSMakeRange(0,[theString
length])];
[theTitle drawInRect:theRect];
[self setFrame: oldFrame];
[self unlockFocus];
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden