Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 11-05-2009, 01:45 PM   #40 (permalink)
pmattf
Registered Member
 
Join Date: Feb 2009
Location: Seattle
Posts: 48
pmattf is on a distinguished road
Default

Well the good news is that I figured it out. The problem was I was using drawInContext, while renderInContext is the one to use....

Code:
	// PDF page drawing expects a Lower-Left coordinate system, so we flip the coordinate system
	// before we start drawing.
	CGContextTranslateCTM(pdfContext, 0.0, pageRect.size.height);
	CGContextScaleCTM(pdfContext, 1.0, -1.0);
	// webView is my UIWebView component
	[webView.layer renderInContext:pdfContext];
The bad news is that this just produces a screen sized bitmap in the pdf, so not that useful.

Quote:
Originally Posted by pmattf View Post
Does anybody know how to take the current contents of a UIWebView and save them into a pdf file?

Using this tutorial as a starting point, I took out everything between CGContextBeginPage and CGContextEndPage.

I first tried
Code:
// webView is my passed in UIWebView *
[webView.layer drawInContext:pdfContext];
The documentation says that UIView's have a layer property of type CALayer *, and CALayer has a drawInContext method. Yet I get a warning that there is no drawInContext method here, and nothing happens when I run it.

Next I tried:
Code:
UIGraphicsPushContext(pdfContext);
[webView setNeedsDisplay];
UIGraphicsPopContext();
Which I think may be closer to the right track, but that still generates an empty pdf file.

Any help would be appreciated.
pmattf is offline   Reply With Quote
 

» Advertisements
» Online Users: 553
19 members and 534 guests
007007, Absentia, Batman, Brian965, BrianSlick, chiataytuday, Duncan C, esoteric, franzwarning, linkmx, mariano_donati, mediaspree, Punkjumper, Rudy, simplymuzik3, skiril, SLIC, Speed
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,318
Threads: 93,988
Posts: 402,408
Top Poster: BrianSlick (7,978)
Welcome to our newest member, Libera
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 10:01 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.