Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PDF in UIWebView

I am creating a magazine app. I am displaying each page of my magazine in a UIWebView. The webview doesn't fill the screen with the PDF though. There is a border around it. How can I display it fullscreen?

like image 319
John Avatar asked Sep 17 '10 01:09

John


2 Answers

I have not tried this with a UIWebView, but you may be able to do something like this to programatically position the border so that it's offscreen:

CGRect frame = webView.frame;
// you may need to modify the 5 and 10 below to match the size of the PDF border
frame.origin.x = frame.origin.x - 5;
frame.origin.y = frame.origin.y - 5;
frame.size.width = frame.size.width + 10;
frame.size.height = frame.size.height + 10;
webView.frame = frame;

If you are using the UIWebView to display PDFs and HTML, you would of course only modify the frame when displaying a PDF, and then set the frame back to the original values when displaying other content.

I have done this type of thing with a UIScrollView for a different reason: to provide padding around the items displayed in the UIScrollView so that there would be a gap in scrolling (as demonstrated in Apple's PhotoScroller example from WWDC 2010). I'm guessing that this could also work to move the borders around the PDF off of the screen.

like image 197
Greg Avatar answered Oct 16 '22 23:10

Greg


Checking the Scale Page to Fit box in IB removed the border for me.

like image 22
mizzle Avatar answered Oct 17 '22 01:10

mizzle