-
-
Save johanoloflindberg/798f1a274dbd9103d04ea7bc7a23414a to your computer and use it in GitHub Desktop.
PDF Rendering white background
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (NSData *)PDFDataForMultiPageDocument { | |
NSMutableData *data = [NSMutableData data]; | |
CGDataConsumerRef consumer = CGDataConsumerCreateWithCFData((CFMutableDataRef)data); | |
if (NULL == consumer) { | |
NSLog(@"could not create consumer"); | |
return nil; | |
} | |
CGRect r = CGRectMake(0.0, 0.0, 800.0, 600.0);; | |
CGContextRef ctx = CGPDFContextCreate(consumer, &r, NULL); | |
CFRelease(consumer); | |
NSGraphicsContext *gc = [NSGraphicsContext graphicsContextWithGraphicsPort:ctx flipped:NO]; | |
CGContextBeginPage(ctx, &r); | |
CGContextSaveGState(ctx); | |
// CGContextClearRect(ctx, r); | |
const CGFloat clearColor[] = {1.0, 1.0, 0.0, 1.0}; | |
CGContextSetFillColor(ctx, clearColor); | |
CGContextFillRect(ctx, CGRectMake(10.0, 10.0, 50.0, 50.0)); | |
CGContextSetStrokeColor(ctx, clearColor); | |
CGContextStrokeEllipseInRect(ctx, r); | |
CGContextRestoreGState(ctx); | |
CGContextEndPage(ctx); | |
CGPDFContextClose(ctx); | |
CGContextRelease(ctx); | |
return data; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment