Skip to content

Commit ba80eeb

Browse files
author
Thomas Taschauer
committed
add support for PDF
1 parent b710c7c commit ba80eeb

3 files changed

Lines changed: 30 additions & 9 deletions

File tree

OpenDocumentReader/DocumentBrowserViewController.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,9 @@ class DocumentBrowserViewController: UIDocumentBrowserViewController, UIDocument
8282

8383
documentViewController.document = doc
8484

85+
let shortenedDocumentUrl = documentURL.absoluteString.prefix(49) + ".." + documentURL.absoluteString.suffix(49)
8586
Analytics.logEvent(AnalyticsEventViewItem, parameters: [
86-
AnalyticsParameterItemName: documentURL.absoluteString
87+
AnalyticsParameterItemName: shortenedDocumentUrl
8788
])
8889

8990
doc.open { [weak self](success) in

OpenDocumentReader/DocumentViewController.swift

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,17 @@ class DocumentViewController: UIViewController, DocumentDelegate {
195195
}
196196

197197
func documentLoadingError(_ doc: Document) {
198-
self.webview.loadHTMLString("<html><h1>Error</h1>Failed to load given document. Please try another one while we are working hard to support as many documents as possible. Feel free to contact us via tomtasche@gmail.com for further questions.</html>", baseURL: nil)
198+
if (doc.fileURL.pathExtension == "pdf") {
199+
self.webview.loadFileURL(doc.fileURL, allowingReadAccessTo: doc.fileURL)
200+
201+
progressBar.isHidden = true
202+
203+
Analytics.logEvent("load_pdf", parameters: nil)
204+
205+
return;
206+
}
207+
208+
self.webview.loadHTMLString("<html><h1>Error</h1>Failed to load given document. Please try another one while we are working hard to support as many documents as possible. Feel free to contact us via support@opendocument.app for further questions.</html>", baseURL: nil)
199209

200210
Analytics.logEvent("load_error", parameters: nil)
201211
}

OpenDocumentReader/Info.plist

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<key>CFBundleTypeIconFiles</key>
1313
<array/>
1414
<key>CFBundleTypeName</key>
15-
<string>ODF</string>
15+
<string>ODT</string>
1616
<key>CFBundleTypeRole</key>
1717
<string>Viewer</string>
1818
<key>LSHandlerRank</key>
@@ -22,6 +22,20 @@
2222
<string>public.zip-archive</string>
2323
</array>
2424
</dict>
25+
<dict>
26+
<key>CFBundleTypeIconFiles</key>
27+
<array/>
28+
<key>CFBundleTypeName</key>
29+
<string>PDF</string>
30+
<key>CFBundleTypeRole</key>
31+
<string>Viewer</string>
32+
<key>LSHandlerRank</key>
33+
<string>Alternate</string>
34+
<key>LSItemContentTypes</key>
35+
<array>
36+
<string>com.adobe.pdf</string>
37+
</array>
38+
</dict>
2539
</array>
2640
<key>CFBundleExecutable</key>
2741
<string>$(EXECUTABLE_NAME)</string>
@@ -34,9 +48,9 @@
3448
<key>CFBundlePackageType</key>
3549
<string>APPL</string>
3650
<key>CFBundleShortVersionString</key>
37-
<string>1.3</string>
51+
<string>1.4</string>
3852
<key>CFBundleVersion</key>
39-
<string>6</string>
53+
<string>7</string>
4054
<key>LSRequiresIPhoneOS</key>
4155
<true/>
4256
<key>UILaunchStoryboardName</key>
@@ -63,9 +77,5 @@
6377
</array>
6478
<key>UISupportsDocumentBrowser</key>
6579
<true/>
66-
<key>UTImportedTypeDeclarations</key>
67-
<array>
68-
<dict/>
69-
</array>
7080
</dict>
7181
</plist>

0 commit comments

Comments
 (0)