• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Looking for a sample for print header & footer
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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:12:49 -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

  • Prev by Date: Looking for a sample for print header & footer
  • Next by Date: Formatter for NSTableView
  • Previous by thread: Re: Looking for a sample for print header & footer
  • Next by thread: Formatter for NSTableView
  • Index(es):
    • Date
    • Thread