Error in iphone: statement failed: (s-> stack-> next! = NULL), function CGGStackRestore, file Context / CGGStack.c, line 116

My code is as follows. I get an error like

Assertion failed: (s-> stack-> next! = NULL), function CGGStackRestore, file Context / CGGStack.c, line 116.

code:

CGPDFPageRef page = CGPDFDocumentGetPage(document, i+1); CGRect pageRect = CGPDFPageGetBoxRect(page, kCGPDFMediaBox); CGFloat pdfScale = width/pageRect.size.width; pageRect.size = CGSizeMake(pageRect.size.width*pdfScale, pageRect.size.height*pdfScale); pageRect.origin = CGPointZero; UIGraphicsBeginImageContext(pageRect.size); CGContextRef context = UIGraphicsGetCurrentContext(); // White BG CGContextSetRGBFillColor(context, 1.0,1.0,1.0,1.0); CGContextFillRect(context,pageRect); CGContextSaveGState(context); CGContextTranslateCTM(context, 0.0, pageRect.size.height); CGContextScaleCTM(context, 1.0, -1.0); CGContextConcatCTM(context, CGPDFPageGetDrawingTransform(page, kCGPDFMediaBox, pageRect, 0, true)); CGContextDrawPDFPage(context, page); CGContextRestoreGState(context); UIImage *thm = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); NSLog(@"Image %@",thm); pdfImage = [[UIImageView alloc] initWithImage:thm]; NSLog(@"Image View: %@",pdfImage); [self.view addSubview:pdfImage]; [self.view reloadInputViews ]; 

Please, help.

+4
source share
1 answer

No CGContextSaveGState until CGContextRestoreGState !

+13
source

All Articles