Taking a break from my programming language blogging, I thought I'd describe a recent adventure with my new iPhone: reading PDFs. The iPhone can read PDFs, but insists on doing so only when reading the PDF from the network in some way, ie. via the mail client or Safari.
Being the programming language enthusiast I am, I have plenty of papers stored locally on my machine which I'd like to read on the go, and network access is less than desirable for obvious reasons. Unfortunately, Apple disabled the obvious answer to local browsing: using the "file://" URI scheme. Very stupid of them IMO.
Fortunately, I'm an "unscrupulous" person, because I jailbroke my iPhone so I could install third-party apps. So if network access is required to view PDFs in Safari, then I'll just have to access local files over the network! The way that's been done for over 20 years is available on the iPhone: a web server.
Both Apache and LightTPD are available in Installer.app, and I chose the latter; I just find the configuration less obtuse than Apache's. You will need OpenSSH installed as well. I also recommend UICtl so you can load/unload the web server only when you need it.
Once everything is installed, I ssh'd to the iPhone, opened the lighttpd config file at /usr/local/etc/lighttpd.conf, changed the root directory to point to /var/root/PDFs (or place it wherever you like), and added:
config line to enable directory browsing. Then using UICtl, I unloaded and reloaded lighttpd.
Finally, I opened up Safari on the iPhone and bookmarked http://127.0.0.1/
Voila! I have access to all my local PDFs via Safari. :-)
Browsing and viewing PDFs is very easy, unlike other schemes using the "data:" URI scheme. Of course, the setup is moderately difficult for anybody who isn't versed in the basics of unix and the command shell.
Naturally, I'd much prefer a native app, or at the very least, local browsing via the file:// URI scheme in Safari. I'm keeping my fingers crossed. :-)
Being the programming language enthusiast I am, I have plenty of papers stored locally on my machine which I'd like to read on the go, and network access is less than desirable for obvious reasons. Unfortunately, Apple disabled the obvious answer to local browsing: using the "file://" URI scheme. Very stupid of them IMO.
Fortunately, I'm an "unscrupulous" person, because I jailbroke my iPhone so I could install third-party apps. So if network access is required to view PDFs in Safari, then I'll just have to access local files over the network! The way that's been done for over 20 years is available on the iPhone: a web server.
Both Apache and LightTPD are available in Installer.app, and I chose the latter; I just find the configuration less obtuse than Apache's. You will need OpenSSH installed as well. I also recommend UICtl so you can load/unload the web server only when you need it.
Once everything is installed, I ssh'd to the iPhone, opened the lighttpd config file at /usr/local/etc/lighttpd.conf, changed the root directory to point to /var/root/PDFs (or place it wherever you like), and added:
dir-listing.activate = "enable"
config line to enable directory browsing. Then using UICtl, I unloaded and reloaded lighttpd.
Finally, I opened up Safari on the iPhone and bookmarked http://127.0.0.1/
Voila! I have access to all my local PDFs via Safari. :-)
Browsing and viewing PDFs is very easy, unlike other schemes using the "data:" URI scheme. Of course, the setup is moderately difficult for anybody who isn't versed in the basics of unix and the command shell.
Naturally, I'd much prefer a native app, or at the very least, local browsing via the file:// URI scheme in Safari. I'm keeping my fingers crossed. :-)
Comments