+ (void)generatePDFByImg:(UIImage *)img andText:(NSString *)text
{
// self.toolBar.hidden = YES;
// NSString *text = @"puma are large cat-like animals which are found in Americ";
CGSize pdfSize;
pdfSize.height = 460;
pdfSize.width = 320;
UIGraphicsBeginImageContext([[UIScreen mainScreen] bounds].size);
// [self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
// UIImage *pdfImage = UIGraphicsGetImageFromCurrentImageContext();
// UIGraphicsEndImageContext();
// self.iiimagev.image = pdfImage;
// UIImage *pdfImage = [UIImage imageNamed:@"10074136.jpg"];
NSMutableData* outputData = [[NSMutableData alloc] init];
CGDataConsumerRef dataConsumer = CGDataConsumerCreateWithCFData((__bridge CFMutableDataRef)outputData);
CFMutableDictionaryRef attrDictionary = NULL;
attrDictionary = CFDictionaryCreateMutable(NULL, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
CGContextRef pdfContext = CGPDFContextCreate(dataConsumer, NULL, attrDictionary);
CFRelease(dataConsumer);
CFRelease(attrDictionary);
UIImage* myUIImage = img;
CGImageRef pageImage = [myUIImage CGImage];
CGPDFContextBeginPage(pdfContext, NULL);
NSLog(@"[myUIImage size].width = %f",[myUIImage size].width);
NSLog(@"[myUIImage size].height = %f",[myUIImage size].height);
CGContextDrawImage(pdfContext, CGRectMake(0,[[UIScreen mainScreen] bounds].size.height,([myUIImage size].width)*2 , ([myUIImage size].height)*2), pageImage);
// NSLog(@"[myUIImage size].width = %f",[myUIImage size].width);
// NSLog(@"[myUIImage size].height = %f",[myUIImage size].height);
详细解决方案
一个关于字符串打印到GraphicsContext上的有关问题
热度:21 发布时间:2016-04-25 05:59:01.0
相关解决方案