我正在使用这种方式生成pdf文件现在它工作正常但背景是白色我想给背景一些颜色所以可以给背景颜色。
- (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();
}