IOS Preview Pdf,word documents in a centralized manner

Source: Internet
Author: User

In the iphone you can easily preview document files, such as PDF, Word, and so on, this article will take the PDF as an example. Introduces three ways to preview PDFs, and compares them from local PDF documents to PDF documents on the Web.

Preview a local PDF document:

1. Using the UIWebView control

UIWebView is one of the most commonly used controls in iphone development, similar to the WebBrowser control in. Net. Using it to preview PDF files is quite handy and simple.

The key code for previewing PDF documents in UIWebView is as follows:

Effect:

2. Using Clpreviewcontroller

Clpreviewcontroller is a relatively new feature that allows you to quickly preview a document and preview it while loading it, meaning you don't need to load the document into memory.

Previewing a PDF file with Clpreviewcontroller requires implementing a delegate: Qlpreviewcontrollerdatasource. The key code is as follows:

Where Prevoewcontroller returns the address of the preview file.

This is not only fast, but also provides a feature for printing documents in the iphone, such as.

3. Drawing PDF Documents

Apple has an official example of drawing a PDF. This way, it is easy to control the presentation details of the PDF, but the efficiency is not high.

To preview a PDF document on the network:

1, use UIWebView to preview the PDF document on the network, first to download the document to preview the iphone memory, and then preview, for a large PDF document, inefficient, user experience is not good.

2, for the use of Prevoewcontroller, because it is step-loaded, not one-time loading all PDF documents, the user experience is good, but in 4.0 more out of a Print button, a click on the Print button, the program hangs, is really a cup.

3, the way to draw is also need to load into memory one time, drawing efficiency is not high, for large documents, should not use this way.

Solutions for large Web document previews: for PDF documents on the Web, such as e-books (some of which are relatively large), it is recommended to download them locally and then use the second way to preview them.

Summary: This article describes three ways to preview PDF documents and is similar for non-PDF documents. Due to my contact with the iphone development is not long, write the wrong place, you are welcome to correct.

This article is code:http://files.cnblogs.com/zhuqil/PDFView.zip

Zhu Qilin
Source: http://zhuqil.cnblogs.com
This article is copyright to the author and the blog Park, Welcome to reprint, but without the consent of the author must retain this paragraph, and in the article page obvious location to the original link, otherwise reserves the right to pursue legal responsibility.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.