• 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
Re : Total number pages being printed
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re : Total number pages being printed


  • Subject: Re : Total number pages being printed
  • From: "Ewan Delanoy" <email@hidden>
  • Date: Sat, 21 Apr 2007 07:29:04 +0200 (CEST)
  • Importance: Normal

 Glen Simmons wrote :

>For instance, if I only want the footer on the  last page, -pageFooter
won't do

If that's all you need to do, -pageFooter is just fine ! The code would
look like this :

-(NSAttributedString*) pageFooter
{
     NSAttributedString* oldFooter=[super pageFooter];
    /* oldFooter is the default built-in footer : "Page x of y", where
     x is the current page and y the number of pages. */

    NSRange pageRange;
    [self knowsPageRange:&pageRange];
    int lastPage=NSMaxRange(pageRange)-1;

    int currentPage=extractFirstFigureFromString([oldFooter string]);
    if (currentPage<lastPage) {
            return @" ";
    }
    // if we get here we are dealing with the last page
	return oldFooter;
}

int extractFirstFigureFromString(NSString* s)
{
      unichar g;
   unsigned i0;
   unsigned i1;
   unsigned len=[s length];
   for (i0=0;i0<len;i0++) {
         g=[s characterAtIndex: i0];
		 if ((47<g)&&(g<58)) break;
   }
  for (i1=i0;i1<len;i1++) {
         g=[s characterAtIndex: i1];
		 if ((g<48)||(57<g)) break;
   }
   return [[s substringWithRange: NSMakeRange(i0,i1-i0)] intValue];

}

       Of course this is only a first draft off the top of my head ; to write
it properly, in the function above you should use
NSCharacterSet.

 HTH,

                      Ewan





_______________________________________________

Cocoa-dev mailing list (email@hidden)

Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Re : Total number pages being printed (From: "Ewan Delanoy" <email@hidden>)
 >Re: Re : Total number pages being printed (From: Glen Simmons <email@hidden>)

  • Prev by Date: subclass of NSManagedObject not behaving as expected
  • Next by Date: Getting default system font
  • Previous by thread: Re: Re : Total number pages being printed
  • Next by thread: Quartz + NSWindow
  • Index(es):
    • Date
    • Thread