| - (void)drawHeaderForPageAtIndex:(NSInteger)pageIndex inRect:(CGRect)headerRect {
 
 NSString *headerText = @"第1次";
 
 
 UIFont *font = [UIFont systemFontOfSize:15];
 
 NSDictionary *textAttributes = @{NSFontAttributeName:font,NSForegroundColorAttributeName:[UIColor blackColor],NSKernAttributeName:@7.5};
 
 CGSize textSize = [self getTextSize:headerText font:font att:textAttributes];
 
 CGFloat offsetX = 20.0;
 
 CGFloat pointX = headerRect.size.width - textSize.width - offsetX;
 CGFloat pointY = headerRect.size.height/2 - textSize.height/2;
 
 [headerText drawAtPoint:CGPointMake(pointX, pointY) withAttributes:textAttributes];
 }
 
 - (void)drawFooterForPageAtIndex:(NSInteger)pageIndex inRect:(CGRect)footerRect {
 NSString *footerText = [NSString stringWithFormat:@"第%lu页共%lu页",
 pageIndex+1 - pageRange.location, (unsigned long)pageRange.length];
 NSDictionary *textAttributes = @{NSFontAttributeName:[UIFont systemFontOfSize: 15] ,NSForegroundColorAttributeName:[UIColor blackColor],NSKernAttributeName:@7.5};
 CGSize textSize = [self getTextSize:footerText font:[UIFont systemFontOfSize:15] att:textAttributes];
 
 
 
 
 
 CGFloat pointX = footerRect.size.width - textSize.width;
 CGFloat pointY = footerRect.origin.y + self.footerHeight/2;
 [footerText drawAtPoint:CGPointMake(pointX, pointY) withAttributes:textAttributes];
 
 
 CGFloat lineOffsetX = 20.0;
 CGContextRef context = UIGraphicsGetCurrentContext();
 CGContextSetRGBStrokeColor(context, 205.0/255.0, 205.0/255.0, 205.0/255, 1.0);
 CGContextMoveToPoint(context, lineOffsetX, footerRect.origin.y);
 CGContextAddLineToPoint(context, footerRect.size.width - lineOffsetX, footerRect.origin.y);
 CGContextStrokePath(context);
 
 }
 
 - (CGSize )getTextSize:(NSString *)text font:(UIFont *)font att:(NSDictionary *)att {
 
 UILabel *testLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, self.paperRect.size.width, self.footerHeight)];
 if (att) {
 
 testLabel.attributedText = [[NSAttributedString alloc] initWithString:text attributes:att];
 }else {
 testLabel.text = text;
 testLabel.font = font;
 }
 [testLabel sizeToFit];
 
 return testLabel.frame.size;
 }
 
 |