I am trying to create a PDF file programmatically in Objective-C and as my data keeps getting larger and larger I need to continue drawing it on the second page. By using the next code I am able to create the necessary number of pages but the content is drawed only on the first one. Any suggestions on what should I change?
+(void)drawPDF:(NSString*)fileName
{
// Create the PDF context using the default page size of 612 x 792.
UIGraphicsBeginPDFContextToFile(fileName, CGRectZero, nil);
// Mark the beginning of a new page.
UIGraphicsBeginPDFPageWithInfo(CGRectMake(0, 0, 612, 792), nil);
int currentPage = 1;
for (int count = 30; count < 3000; count = count + 100) {
//add new PDF page if the content doesn't fits on the curent one
if (currentPage * 792 < count + 30) {
currentPage ++;
UIGraphicsBeginPDFPage();
}
[self drawCellFromStartingPoint:count];
}
// Close the PDF context and write the contents out.
UIGraphicsEndPDFContext();
}