BNHtmlPdfKit icon indicating copy to clipboard operation
BNHtmlPdfKit copied to clipboard

Issue with Footer

Open javalnanda opened this issue 10 years ago • 1 comments

Hi, while generating pdf from the html the footer always appears in the next page above header. I tried different page sizes but still the issue persists. Is there any specific way to render footer for each page?

javalnanda avatar Apr 24 '14 05:04 javalnanda

Hello, I have modified BNHtmlPdfKit.m to add footer text. override the - (void)drawFooterForPageAtIndex:(NSInteger)pageIndex inRect:(CGRect)footerRect;

@implementation BNHtmlPdfKitPageRenderer ....

- (void)drawFooterForPageAtIndex:(NSInteger)pageIndex  inRect:(CGRect)footerRect{
    NSLog(@"footerRect=%@",NSStringFromCGRect(footerRect));
    NSString *footerText = [NSString stringWithFormat:@"Page-%ld",pageIndex+1];
    NSDictionary *attributes = @{
                                 NSFontAttributeName: [UIFont fontWithName:@"Helvetica" size:10.0],
                                 NSForegroundColorAttributeName : [UIColor grayColor]
                                 };
    // page number at right edge of footer rect
    CGSize pageNumSize = [footerText sizeWithAttributes:attributes];
    CGFloat drawX = CGRectGetMaxX(footerRect) - pageNumSize.width - 1.0;
    CGFloat drawY = CGRectGetMaxY(footerRect) - pageNumSize.height;
    CGPoint drawPoint = CGPointMake(drawX, drawY);
    [footerText drawAtPoint:drawPoint withAttributes: attributes];
}

wisaruthk avatar Sep 01 '15 10:09 wisaruthk