BNHtmlPdfKit
BNHtmlPdfKit copied to clipboard
Issue with Footer
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?
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]; }