2

If I load a PDF into a UIWebView:

if (!bundle)
    bundle = [NSBundle mainBundle];

NSString *filePath = [bundle
                      pathForResource:fileName ofType:@"pdf"];

UIWebView *webView = [[[UIWebView alloc] initWithFrame:view.bounds] autorelease];
webView.scalesPageToFit = YES;
[view addSubview:webView];


NSURL *pdfURL = [NSURL fileURLWithPath:filePath];

NSURLRequest *request = [NSURLRequest requestWithURL:pdfURL];
[webView loadRequest:request];

the app acts just like Mobile Safari except when it has to do paging:

Mobile Safari pages without pause, showing the parts that it is rendering as checkerboard. UIWebView, in contrast, stops movement, and eventually jerks to the new position.

MobileSafari works nicely and UIWebView is unacceptable. What other options do I have for displaying a multipage PDF? Or do I need to handle the multipage aspect by myself using CGPDFPageRef?

1 Answer 1

1

EDIT Just realized that the link refers to OS X programming, not iOS. Sorry.

Hello,

I tried out some similar code I ran into the same issue, so there is definitely some difference between the browser and the UIWebView.

In researching the problem I can across this SO thread: "PDF in webview performance" I think the last post may help you out.

EDIT 2:

The solution I would use is to convert your PDF into an image, and load that in an imageview with scrolling. Initially it might take a moment to load, but the scrolling action will be smooth and will not lag.

2
  • Very interesting link. In line with your Edit 2, I found this iosguy.com/2010/09/04 that works pretty nicely. Jan 21, 2011 at 13:34
  • The QuickLook stuff is great. Thanks for getting me over there. Jan 21, 2011 at 16:48

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.