Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with Footer #5

Open
javalnanda opened this issue Apr 24, 2014 · 1 comment
Open

Issue with Footer #5

javalnanda opened this issue Apr 24, 2014 · 1 comment

Comments

@javalnanda
Copy link

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?

@wisaruthk
Copy link

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];
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants