UIWebView With PDF

2019-05-18 07:15发布

I'm displaying a PDF file using UIWebView, and I want to do 2 things:

  1. I want to make the page fit the phone screen without the user has to double tap to do that

  2. I want to remove the margin with gray shadow around the displayed PDF

Thanks for helping

5条回答
对你真心纯属浪费
2楼-- · 2019-05-18 07:24

Where has CGAFFineTransformScale been all my life?

Seriously, that is a big help. However, it worked better applying it to webView.scrollView.

Finally, is there a similar command to change the offset of the content as well as the scale?

查看更多
我想做一个坏孩纸
3楼-- · 2019-05-18 07:33

2 - Checking the Scale Pages to Fit box in IB sorted this for me

I would also like to know the answer to 1. I guess you want to know how to display the PDF in the same way as when opening as attachment in mail, where the navigation bar only appears on a tap and the status bar also disappears?

查看更多
一夜七次
4楼-- · 2019-05-18 07:34
webView.transform = CGAffineTransformScale( webView.transform, 1.25, 1.25 );
查看更多
爷、活的狠高调
5楼-- · 2019-05-18 07:44

I don't think this will help much, but I think your best option is to render the PDF to an image (of decent DPI) and show the image instead. I do this for an app, but we do that server side using ImageMagick - don't know how you might do that in obj-c. Also note that a mostly-text PDF will be much larger (filesize) when rasterized.

However, you might also try to embed the PDF in HTML page and load that HTML in the WebView - that may at least avoid the gray border/artboard.

查看更多
登录 后发表回答