Reputation: 129
i am generating pdf file using this way now it works fine but background is white i want to give some color to background so is it possible to give backgorund color.
- (void) generatePdfWithFilePath: (NSString *)thefilePath
{
UIGraphicsBeginPDFContextToFile(thefilePath, CGRectZero, nil);
NSInteger currentPage = 0;
BOOL done = NO;
do
{
UIGraphicsBeginPDFPageWithInfo(CGRectMake(0, 0, pageSize.width, pageSize.height), nil);
currentPage++;
[self drawPageNumber:currentPage];
//Draw a border for each page.
[self drawBorder];
//Draw text fo our header.
[self drawHeader];
//Draw a line below the header.
[self drawLine];
//Draw some text for the page.
[self drawText];
//Draw an image
[self drawImage];
done = YES;
}
while (!done);
UIGraphicsEndPDFContext();
}
Upvotes: 3
Views: 1181
Reputation: 10354
Use this code inside do while loop
CGContextRef currentContext = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(currentContext, [UIColor redColor].CGColor );
CGContextFillRect(currentContext, pdfpageFrame);
This will solve your Problem
Upvotes: 6