Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

medasmx

macrumors member
Original poster
Nov 9, 2008
89
0
Code:
- (void)viewDidLoad {
	
	NSString*path=[[NSBundle mainBundle]pathForResource:@"sample2" ofType:@"pdf"];	
	//Create a URL object.
	NSURL *url = [NSURL fileURLWithPath:path];
	
	//URL Requst Object
	NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
	
	//Load the request in the UIWebView.
	[webView loadRequest:requestObj];
	
	UIGraphicsBeginImageContext(webView.bounds.size);
	[webView.layer renderInContext:UIGraphicsGetCurrentContext()];
	UIImage*someImage=UIGraphicsGetImageFromCurrentImageContext();
	UIGraphicsEndImageContext();
	
	self.myImageView.image=someImage;
}

I created a view-based application, where in the view the screen is split between a webView object and a imageView object in the IB. The pdf shows up fine in the webView, but nothing appears in the imageView. Any ideas? Thanks.
 
I solved the problem using quartz and the code below. The sample code (from apple) "QuartzDemo" was what I used to generate the PDF. Seems simpler than using a webview anyway.

Code:
	CGContextSelectFont(context, "Helvetica", 36, kCGEncodingMacRoman);
	CGContextSetTextDrawingMode(context, kCGTextFill);
	const char*text="hello there";
	CGContextShowTextAtPoint(context, 100, 100, text, strlen(text));
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.