UIWebView: How do I control page display with a PDF? - iphone

I have a PDF loaded in an iPhone app using UIWebView and it displays page numbers when the pages are scrolled manually. But I've had no luck figuring out how to access those numbers and set the page displayed. Any suggestions would be welcomed. Thanks.

There's no way to do this using the methods available through the SDK. If you really need this functionality you can file a bug report.

Since you're using a uiwebview it can interpret javascript for navigation, even with a pdf. determine the pixel size of each page, and you can theoretically calculate your location on any given page and and navigate accordingly.

You can do this using Quartz Core Api in Iphone SDK.

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

Get the length of the scroll view content and then divide it by page number.
That will give you length of each page. There is a way to get number of pages from uiwebview.

Related

UIScrollView application (w/ paging enabled) to load images only relevant to current page

I am wondering if anyone can offer any advice towards solving this problem.
I am building an app that uses a UIScrollView with paging enabled, with each page corresponding to downloaded and parsed XML data. Part of that XML data is a URL to an image.
Now, it would take forever to load an app that downloads the image for every XML entry and then push it to the respective UIScrollView page created on runtime with the rest of the XML data.
Is there a way to be able to detect which UIScrollView page you are on and then download the image as needed and still allow the rest of the data to download at runtime?
Try to read SDWebImage or Apple's LazyTableImages
Just as referenece, I solved it by adding all of the image views into an NSArray. Using the scroll view delegate, I was able to determine which page number I was on, and translated that page number to an integer that I used to access the appropriate uiimage view located within the array.
It seems to work great!
Might you offer a better solution?

how to load the pdf through programming with animation in iphone

how load a pdf into iphone and my pdf is of 200 pages then it should allow to turn the pages as we do with while reading book manually means use animation to turn a page one by one ..
Thanking you ..
Loading a large PDF and having page flipping animation isn't very simple. You can use a UIWebView like #Jim says to load the entire thing by just pointing the UIWebView's URL to the PDF but you won't get page animation. However to get full control requires that you render the PDF page by page manually to a view, and create the view's turning animation your self. Its nontrivial, and given your question you don't sound like you know enough to realistically achieve this right off.
Use UIWebView Control to load pdf files.

iphone PDF view CGPDFDocument

I am developing an app where I need to show PDF documents. After many hours of googling I was able to build up a view to show the PDF document fetched from a URL.
I know only to display a single page. using CGPDFDocumentGetPage(ref, pageNumber).
What I would like to have.
Pagination function.
Zoom
Scrolling
Why not using the UIWebView instead of reinventing the wheel?

iPhone UIWebView PDF Page Jump

I want to view a local PDF (in my iPhone app) and be able to jump to a specific page. Seems like the UIWebView is the way to go, however, I can't find any information on jumping to specific pages. Is this impossible? Are there any other techniques I can use?
thanks,
Howie
You can try using Javascript. See this link for more details. You'll want to use something along the lines of #"window.scrollTo(0, x);", where x is some value you determined by playing around with the WebView.
Another option would be to set the content offset of the UIWebView like Mike pointed out (but without involving JavaScript):
webView.ScrollView.SetContentOffset(new PointF(0, y), true);
(sorry for the MonoTouch code but ObjectiveC is still on my todo list)
Alternatively to an UIWebView, you can use the Quartz API :http://developer.apple.com/iphone/library/documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/dq_pdf/dq_pdf.html
It's more complicated, but you should be able to do whatever you want.

UIWebView With PDF

I'm displaying a PDF file using UIWebView, and I want to do 2 things:
I want to make the page fit the phone screen without the user has to double tap to do that
I want to remove the margin with gray shadow around the displayed PDF
Thanks for helping
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.
webView.transform = CGAffineTransformScale( webView.transform, 1.25, 1.25 );
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?
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
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?