Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Looking for a sample for print header & footer



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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.