PDF not showed correctly in UIWebView
I have a UIWebView in which I want to display a PDF file. The PDF file is located on a remote webserver and is therefore loaded like any other URL.
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.findsmiley.fvst.dk/KontrolRapport.aspx?id=20328832&akt=1"]]];
The PDF is not displayed correctly, though. I am not able to scroll or zoom the document. In the console I get the following error codes (CafeHelmuth being the name of my application, of course)
Wed Mar 23 15:56:31 simonbs-macbook CafeHelmuth[1997] <Error>:
Wed Mar 23 15:56:31开发者_JS百科 simonbs-macbook CafeHelmuth[1997] <Error>:
Wed Mar 23 15:56:31 simonbs-macbook CafeHelmuth[1997] <Error>:
Wed Mar 23 15:56:31 simonbs-macbook CafeHelmuth[1997] <Error>:
Wed Mar 23 15:56:31 simonbs-macbook CafeHelmuth[1997] <Error>:
Wed Mar 23 15:56:31 simonbs-macbook CafeHelmuth[1997] <Error>:
Wed Mar 23 15:56:31 simonbs-macbook CafeHelmuth[1997] <Error>:
Wed Mar 23 15:56:31 simonbs-macbook CafeHelmuth[1997] <Error>:
Terminating in response to SpringBoard's termination.
Program ended with exit code: 0
On the image below you see that it does not scroll the web page but the view, which, of course, is wrong.
Can anyone please help me make my web view display the PDF document correctly?
Adding webView.scalesPageToFit = YES;
before loadRequest
makes it look a bit strange, though it does add zoom and scroll but it does not seem to be the right approach. Beneath are some images of this.
When I zoom in the background becomes blue and.. Well, it looks strange.
Add a line
webView.scalesPageToFit = YES;
before the loadRequest line
I didn't find any solution to customize the behaviour of the webview. But I have found a solution for your pdf: Change the pdf's format to 10.7 cm x 15.7 cm. Have a look at this example:
精彩评论