Mina Mikhael
Mina Mikhael

Reputation: 2835

UIWebView With PDF

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

Upvotes: 3

Views: 4250

Answers (5)

user2844331
user2844331

Reputation: 119

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?

Upvotes: -1

mizzle
mizzle

Reputation: 578

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?

Upvotes: 1

Jeff
Jeff

Reputation: 2699

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

Upvotes: 1

Jason
Jason

Reputation: 1433

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.

Upvotes: 1

Related Questions