I am having a problem in creating the multi page PDF. I am using NSData for storing the PDF data. It takes more than 2 minutes to generate the PdfData. It shows following error in ios 10
<Error>: replacing +/-infinity with -2147483647.
<Error>: replacing +/-infinity with 2147483648.
<Error>: replacing +/-infinity with -2147483647.
<Error>: replacing +/-infinity with 2147483648.
<Error>: replacing +/-infinity with -2147483647.
<Error>: replacing +/-infinity with 2147483648.
<Error>: replacing +/-infinity with -2147483647.
<Error>: replacing +/-infinity with 2147483648.
Can't find solution for this Please help me on this...
Code for generating PDF
-(NSData *)getPdf:(UITableView *)tableView{
// -- first page height, rest pages height: adjust to get it right
#define FIRST_PAGE_HEIGHT 1160
#define REST_PAGES_HEIGHT 1130
CGSize fittedSize;
CGRect savedFrame = tableView.frame;
CGRect priorBounds = tableView.frame;
priorBounds.size.width=768;
tableView.frame = priorBounds;
fittedSize = [tableView sizeThatFits:CGSizeMake(priorBounds.size.width, ([tableView numberOfRowsInSection:0] * 49) + 829)];
tableView.bounds = CGRectMake(0, 0, fittedSize.width, fittedSize.height);
CGRect pdfPageBounds;
// Standard US Letter dimensions 8.5" x 11"
pdfPageBounds = CGRectMake(0, -15, 768, REST_PAGES_HEIGHT);
NSMutableData *pdfData = [[NSMutableData alloc] init];
UIGraphicsGetCurrentContext();
UIGraphicsBeginPDFContextToData(pdfData, pdfPageBounds, nil);
// - page# setup
UILabel *refnoLabel = (UILabel *)[tableView viewWithTag:8888];
int pageno=0;
{
// do page1 separately
CGRect pdfPageBoundsPage1 = CGRectMake(0,0,768, FIRST_PAGE_HEIGHT+15);
UIGraphicsGetCurrentContext();
UIGraphicsBeginPDFPageWithInfo(pdfPageBoundsPage1, nil);
{
CGContextTranslateCTM(UIGraphicsGetCurrentContext(), 10, 0);
[tableView.layer renderInContext:UIGraphicsGetCurrentContext()];
[@"Page 1" drawAtPoint:CGPointMake(340.0, 10.0)
withAttributes:@{NSFontAttributeName:[UIFont fontWithName:@"Helvetica" size:24],NSForegroundColorAttributeName:[UIColor blackColor]}];
pageno ++;
}
// start from 2nd page
for (CGFloat pageOriginY = FIRST_PAGE_HEIGHT; pageOriginY < fittedSize.height; pageOriginY += REST_PAGES_HEIGHT)
{
UIGraphicsBeginPDFPageWithInfo(pdfPageBounds, nil);
{
CGContextTranslateCTM(UIGraphicsGetCurrentContext(), 10, -pageOriginY+15);
[tableView.layer renderInContext:UIGraphicsGetCurrentContext()];
NSString *pageString = [NSString stringWithFormat:@"Ref#:%@ Page %i", refnoLabel.text, pageno+1 ];
[pageString drawAtPoint:CGPointMake(330, REST_PAGES_HEIGHT * pageno +30)
withAttributes:@{NSFontAttributeName:[UIFont fontWithName:@"Helvetica"
size:14]}];
pageno ++;
}
}
}
UIGraphicsEndPDFContext();
tableView.bounds = priorBounds;
// 140208 dan - Comment: restored the saved WIDTH
tableView.frame=savedFrame ;
return pdfData;
}