forked from vfr/Reader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
README
207 lines (153 loc) · 6.93 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
Basic PDF Reader/Viewer V2.3 for iOS
INTRODUCTION
============
I've written this basic PDF reader/viewer app for fellow iOS
developers struggling with wrangling PDF files onto iOS device
screens. Version 2.x is a complete rethink and rewrite of the
original 1.x code. Please see my contact info below if you find
any bugs or have questions about the code.
The code is universal and does not require any XIBs (as all UI
elements are code generated, allowing for greatest flexibility).
It runs on iPad, iPhone and iPod touch with iOS 4.0 and up. Also
supported are the Retina displays on iPhone 4 and iPod touch 4th
generation and is ready to be fully internationalized. The idea
was to provide a complete project template that you could start
building from, or, just pull the required files into an existing
project to enable PDF reading/viewing in your app(s).
After launching the sample app, tap on the left hand side of the
screen to go back a page. Tap on the right hand side to go to the
next page. You can also swipe left and right to change pages. Tap
on the screen to fade in the toolbar and page slider. Double-tap
with one finger (or pinch out) to zoom in. Double tap with two
fingers (or pinch in) to zoom out.
This implementation has been tested with large PDF files (over
250MB in size and over 2800 pages in length) and with PDF files of
all flavors (from text only documents to graphics heavy magazines).
It also works rather well on older devices (such as the iPod touch
2nd generation and iPhone 3G) and takes advantage of the dual-core
processor (via CATiledLayer and multi-threading) in the iPad 2.
FEATURES
========
Multithreaded: The UI is always quite smooth and responsive.
Supports:
- iBooks like document navigation.
- Device rotation and all orientations.¹
- Encrypted (password protected) PDFs.
- PDF links (URI and go to page).
- PDFs with rotated pages.
NOTES
=====
Version 2.x of the PDF reader/viewer code was developed and tested
under Xcode 3.2.6, LLVM 1.7, iOS 4.3.5 and iOS 4.2.1 - if you come
across any issues with other versions of the tools, or iOS, please
do let me know.
The overall PDF reader/viewer functionality is encapsulated in the
ReaderViewController class. To present a document with this class,
you first need to initialize a ReaderDocument object with the file
path to the PDF document - or unarchive an existing ReaderDocument
property list - and then initialize a new ReaderViewController with
this ReaderDocument object. The ReaderViewController class uses the
ReaderDocument class to store information about the document and to
keep track of document properties (bookmarks and the current page
number for example).
An initialized ReaderViewController can then be presented
modally, pushed onto a UINavigationController stack, placed in
a UITabBarController tab, or be used as a root view controller.
Please note that since ReaderViewController implements its own
toolbar, you need to hide the UINavigationController navigation
bar before pushing it and then show the navigation bar after
popping it. The ReaderDemoController class shows how this is
done with a bundled PDF file.
Required Files
--------------
The following files are required to incorporate the PDF
reader/viewer into one of your projects:
CGPDFDocument.h CGPDFDocument.m
ReaderDocument.h ReaderDocument.m
ReaderConstants.h ReaderConstants.m
ReaderViewController.h ReaderViewController.m
ReaderMainToolbar.h ReaderMainToolbar.m
ReaderMainPagebar.h ReaderMainPagebar.m
ReaderContentView.h ReaderContentView.m
ReaderContentPage.h ReaderContentPage.m
ReaderContentTile.h ReaderContentTile.m
ReaderScrollView.h ReaderScrollView.m
ReaderThumbCache.h ReaderThumbCache.m
ReaderThumbRequest.h ReaderThumbRequest.m
ReaderThumbQueue.h ReaderThumbQueue.m
ReaderThumbFetch.h ReaderThumbFetch.m
ReaderThumbRender.h ReaderThumbRender.m
ReaderThumbView.h ReaderThumbView.m
ReaderThumbsView.h ReaderThumbsView.m
ThumbsViewController.h ThumbsViewController.m
ThumbsMainToolbar.h ThumbsMainToolbar.m
Reader-Email.png [email protected]
Reader-Mark-N.png [email protected]
Reader-Mark-Y.png [email protected]
Reader-Print.png [email protected]
Reader-Thumbs.png [email protected]
Localizable.strings (UTF-16 encoding)
Required iOS Frameworks
-----------------------
To incorporate the PDF reader/viewer into one of your projects,
all of the following iOS frameworks are required by the code:
UIKit Foundation
CoreGraphics QuartzCore
ImageIO MessageUI
Compile Time Options
--------------------
In ReaderConstants.h the following #define options are available:
READER_BOOKMARKS - If TRUE, enables page bookmark support.
READER_ENABLE_MAIL - If TRUE, an email button is added to the toolbar
(if the device is properly configured for email support).
READER_ENABLE_PRINT - If TRUE, a print button is added to the toolbar
(if printing is supported and available on the device).
READER_ENABLE_THUMBS - If TRUE, a thumbs button is added to the toolbar
(enabling page thumbnail document navigation).
READER_DISABLE_IDLE - If TRUE, the iOS idle timer is disabled while
viewing a document (beware of battery drain).
READER_SHOW_SHADOWS - If TRUE, a shadow is shown around each page
and the page content is inset by a couple of extra points.
READER_STANDALONE - If FALSE, a "Done" button is added to the toolbar
and the -dismissReaderViewController: delegate method is messaged when
it is tapped.
ReaderDocument Archiving
------------------------
To change where the property list for ReaderDocument objects is stored
(~/Documents by default), please see the +archiveFilePath: method in the
ReaderDocument.m source file. Note that the ReaderDocument object data
model is Core Data compatible.
Caveats
-------
¹ There appears to be a bug in iOS 4.x with view controller rotation
handling when a modal view controller is presented from a modal view
controller which is in a UINavigationController on small devices. For
this reason, landscape support has been disabled on iPhone and iPod
touch for now.
HISTORY
=======
2011-07-29: Version 2.0.0
- Released v2.0 into the wild for general use.
2011-08-25: Version 2.1.0
- Added PDF link (URI and document page) support.
- Assorted code cleanup, optimizations and bug fixes.
2011-08-27: Version 2.1.1
- Fixed rotation handling when in a UITabBarController.
2011-09-09: Version 2.2.0
- A medium resolution page preview image is now shown first.
- The page bar now uses small page thumbs instead of a slider.
2011-09-10: Version 2.2.1
- Added password handling to ReaderDocument plist unarchive.
2011-09-14: Version 2.3.0
- Added page thumbnail document navigation.
- Added support for page bookmarks.
- Some more assorted bug fixes.
CONTACT INFO
============
Questions, feedback and iOS development work welcome:
Email: joklamcak(at)gmail(dot)com
Website: http://www.vfr.org/
ACKNOWLEDGEMENTS
================
The PDF link support code in the ReaderContentPage class is based on
the links navigation code by Sorin Nistor from http://ipdfdev.com/