UIWebView With PDF

血红的双手。 提交于 2019-12-22 10:55:16

问题


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


回答1:


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.




回答2:


webView.transform = CGAffineTransformScale( webView.transform, 1.25, 1.25 );



回答3:


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:


You can also use Quartz to do it, as explained here : http://developer.apple.com/iphone/library/documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/dq_pdf/dq_pdf.html




回答5:


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?



来源:https://stackoverflow.com/questions/1389271/uiwebview-with-pdf

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!