in my iPhone application i am loading a pdf file on UIWebview. I PDF URL is called from the webserver. My problem is that it is taking a lot of time to display the PDF File. Can any one please suggest me how can i make it bit fast.
Thanks!
Most likely, you cannot eliminate the latency in:
downloading your pdf from the web
displaying the pdf in the UIWebView
but you may be able to hide the latency by preparing the data before you need to display it in a background operation. The NSOperationQueue and NSOperation class make doing this relatively straightforward. Load the data in an NSOperation, save it to a temporary file, assign it to display in a "offscreen" UIWebView (one whose frame makes it not display on the screen), and when you finally need to display the pdf, just place the UIWebView into your current view or move it onscreen by changing its frame.
If you have control over the pdf itself, you can use Acrobat to optimize it for downloading and electronic viewing.
In Acrobat 10, use either the PDF Optimizer command, or the Preflight tool (select Online Publishing 'optimize for size')
Webview is very slow in rendering the PDF. Using native CGPDFDocument API will be fast, but you need to handle the complex loading and rendering process.
Related
I display html string on UIWebview, and html string comes from server.
In html which I retrieved from server, is having 10 images which are large sized with src attribute. those images total size is above 4 MB. when I load this html string into UIWebview, application takes 4 mins to load images sometimes and sometimes it crashes.
I want to know, if there is any solution to <img src..> tag where I can make thumbnail images.
Any response will greatly appreciated.
Thanks
You should be able to find out on the server-side via java/html5 what browser your client is and what features it has. In doing so the server can determine the appropriate image size to send to the client.
My company has successfully implemented this with iPhone and Android client's retrieving images that are smaller in size as opposed to browser's on laptops receiving larger images.
Good luck!
Big chunks of memory allocated can trigger a sigkill 9 from springboard on heavy system load (by protection) even if you don't overlap the 46MB given for any single application running.
The best way to do this would be to load one image at a time.
For each individual image, create a smaller version.
Release the currently big image loaded since you have a smaller version of it.
Do it again for next, and so on.
You will reduce the impact of big loads.
The Nimbus Framework is doing image download and resize that way. Have a look.
For the UIWebview, I'm not sure of what you can do. Since you get the HTML before displaying it, you could perhaps grep the <img> tags and creating those thumbnails, storing them to the iPhone, replacing the src path of the original <img> tags by a local URL of your thumbs.
Probably the device you are using cannot support 4MB images when decompressed in a UIWebView.
Which device are you using?
4 minutes to load 4 images is a very long time. Is your network very bad? Otherwise it could be another indicator of wrong approach.
Being you I'll try to use native UIImageView to display the images and perform some kind of queued download, maybe with ASIHTTP.
So you can load and unload the images when you need them and avid keeping them always in memory.
As Jojas point, I still think that the answer is correct as the UIWevView drains memory to render the DOM elements.
Good day.
I have a UIWebView that loads a big article with 10+ images. HTML code is stored locally, images are loaded by UIWebView automatically.
Sometimes web view won't load all of the images (for example, 3 out of 10). It doesn't depend on a connection type (EDGE/WiFI), image amount (sometimes web view loads 20 out of 20 images, sometimes doesn't load 3 out of 5).
As for now the only way to fix this as I understand is parsing <img> tags in HTML and loading images programmatically to a local cache for future displaying.
Any thoughts? Is there any way to control UIWebView's image loading?
Thank you.
I've recently had the same issue on another project: some images were displaying as half black only on slow connections like GPRS/EDGE. The reason was that my client's web server had a limit for connection time when downloading images. If you've run into similar issue don't forget to check that.
I have an application that frequently checks in with a server and downloads a batch of articles to the iphone. The articles are in html and just stored using core data.
An article has 0-n images on the page.
Downloading all associated images at the same time as the text will be too slow and take too much bandwidth. Users are not likely to open every article. If they open an article once it is likely they will open it several times.
So I want to download and store the images locally when they are needed.
These articles are listed in a UITableView. When you tap an article you pop open a UIWebView that displays the article.
I have a function that checks if I have downloaded the images associated with the article already. If I have I just pop open the the UIWebView - everything works fine.
If I don't have the images downloaded I go off and download them and store them to my Documents directory. Although this i working, the app is hanging while the images are downloading. Not very tidy.
I want the article to open in a snap and download the images with the article open.
So what I've done is I check if the images are downloaded, if they aren't I go ahead and just "touch" the files I need and load the webview. The UIWebView opens up but the images referenced contain no data. Then in a background thread I download the images and overwrite the "dummy" ones.
This will save the images and everything but it won't reload the images in my current UIWebView. I have to go back out of the article back back in again to see the images.
Are there any ways around this? reloading just an image in a UIWebView?
Try to reload image with javascript.
Like this:
[webView stringByEvaluatingJavaScriptFromString:#"$('img').attr('url','http://123.com/icon.png')"];
I don't know if you can reload just the images (I guess you can't... but I'm not sure)
I would try to reload the content with
[webView reload];
I am currently using QLPreviewController to view PDFs (250MB+) However it cannot deal with real large files. Either I get the info that not the whole file has been loaded or the whole app just dies.
I also need to customize the view which is nit possible using QLPreviewController.
What should I do? Use UIWebView instead? Or will I have to use CGContextDrawPDFPage?
Using the latter, how will I get zooming implemented?
I would go with your suggestion of using a UIWebView. Doing so will automatically give you zoom support and the UIWebView should handle loading extremely large PDF's.
If you have decided to go with Quartz, this link looks very promising for zoom support.
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.