Results 1 to 19 of 19

Your favorite Apple, iPhone, iPad, iOS, Jailbreak, and Cydia site.


Thread: apache and safari as PDF ebook reader

  1. #1
    Default apache and safari as PDF ebook reader
    I have been looking for an ebook reader that recognizes PDF ebooks. Books.app doesn't seem to and I can't get mobilepreview to see them either. As a workaround I'm using apache and safari.

    Basically, install apache from installer.app
    It will make a folder called Library/Webserver/documents
    Put folder of PDF ebooks in there.
    Point safari to 127.0.0.1/(your folder name)/
    You get a directory listing of folder contents.
    Click on any PDF and it will open in safari complete with zooming, rotation capabilities, graphics & page numbers...etc
    Wonky but it works.

    I would rather use a designated PDF reader so if anyone knows of one please let me know.

    Additionally - if anyone knows of another way for Safari to read local files, that would work too.

    Greg
    Last edited by hartsteins; 09-08-2007 at 04:36 PM. Reason: addition

  2. The Following User Says Thank You to hartsteins For This Useful Post:

    thinkfast (11-08-2007)

  3. #2
    could you use that method to store web apps locally? because that would be amazing....

  4. #3
    Many Thanks.

    Your Apache webserver idea also solves my need to view images at a higher res than the standard photo viewer on the itouch supports, and in regard to brett's question, it appears to be able to fully function as a webserver. Anyone else see the potential here?! For my needs I can see building my own web-based (but hosted on the ipod touch itself) photo management system that is totally customized to my own liking. Amazing indeed.

    Mel

  5. #4
    Given the resource constraints of the iPhone, I would think that lighttpd is a better choice. I configured mine with a custom PHP directory listing script and corresponding CSS sheet to look more standardized.
    Attached Thumbnails Attached Thumbnails -img_9000.png  

  6. The Following User Says Thank You to DeathPrawn For This Useful Post:

    thinkfast (11-09-2007)

  7. #5
    Looks nice. Would you mind sharing the code?

    Mel

    Just tried the lighttpd. It is much better performing. Thanks. I was having trouble with large pdf's freezing for up to a minute before, problem gone.

    Mel
    Last edited by thinkfast; 11-09-2007 at 10:24 AM. Reason: Automerged Doublepost

  8. #6
    I've attached the PHP, CSS, and image files. Throw 'em all into a folder called .dirlist at the root of the site folder - you can change it, but be sure to change all references in the PHP, CSS, and lighttpd.conf files.

    You also need to make the following changes to your lighttpd.conf (this is assuming you already have both directory listing and PHP set up properly):
    - add "mod_indexfile" to the list of server modules, separated by a comma
    - add the line 'index-file.names = ( "/.dirlist/dir-generator.php" )' (change if you want to keep it somewhere else).

    load/unload lighttpd, and it should work!
    Attached Files Attached Files
    Last edited by DeathPrawn; 11-09-2007 at 07:43 PM.

  9. The Following 2 Users Say Thank You to DeathPrawn For This Useful Post:

    -V-O-Y-A-G-E-R- (03-05-2008), DaveiPhone (11-09-2007)

  10. #7
    Is there maybe an...easier way...of reading PDF's on the iPhone?

  11. #8
    DeathPrawn, thanks much for posting that! This is a slick solution and works great, although as a newbie to lighttpd and PHP, it took a little bit for me to figure out how to make it work.

    Even though this shows off my extreme ignorance, maybe others will benefit by my explaining the steps that slowed me down:

    First, I had to figure out that PHP was a separate installation! Yes, I said I'm a newbie. When you install PHP, you get this message: "Please add /opt/iphone/bin/ to your $PATH", but it did actually did that automatically.

    Next I needed to locate the lighttpd.conf file so I could modify it. It's here:
    /usr/local/etc/lighttpd.conf

    In addition to the changes you noted, I also had to add in cgi.assign array, this to the end : , ".php" => "/opt/iphone/bin/php-cgi"

    After that (and following all DeathPrawn's instructions), it worked like a treat!

    All hail DeathPrawn!! Really nice, thanks again.

  12. #9
    Default Q
    I install apache and then open to safari and type in the web address where I get a message from apache saying software successfully installed.

    I then use mobile finder to navigate to library but there is no WebServer folder and I can't find any file called index.html

    Am i supposed to create the webserver and documents folders manually?

    any help appreciated

    No worries figure it out but safari doesn't seem to be able to open all PDFs, sometimes it just gives a grey page.
    Last edited by bobjames; 11-17-2007 at 07:18 AM. Reason: Automerged Doublepost

  13. #10
    Guys, I tried this lighttpd way but I don't know what to key in Safari window in order to go to that view DeathPrawn posted. Can u try and do a step by step little guide as I might have put a line at the wrong place in lighttpd.conf.

    Also is there a way not to have space problems when uploading pdf boooks?

    Thanx in advance...

  14. #11
    it works great .... it's so much easier to read a pdf/txt in safari than in any pdf readear or books ... large files one fast, you can play with landscape and portrait ....

    one single problem: maybe you guys can help me!?

    when in offline mode, i can't use safari! ... i get the "safari can't open the page because it can't find the server." message ....

    but these files are local files ....

    is there a trick that can be done?!

    Thanx!

  15. #12
    Livin the iPhone Life Eurisko's Avatar
    Join Date
    Aug 2007
    Location
    Toronto, Canada
    Posts
    3,308
    Thanks
    12
    Thanked 562 Times in 483 Posts

    Quote Originally Posted by brettt View Post
    could you use that method to store web apps locally? because that would be amazing....
    Yes, I've been doing that for while. You can store entire websites locally and access them via Safari. I mainly store games, and information sites.

    Books.app only reads Txt and HTML. If you want a PDF Reader you can get one through the installer. It's called PDFViewer, available through Conceited's Installer Repository.
    Get "iPod & iTunes for Dummies", it'll change your life.

  16. #13
    "when in offline mode, i can't use safari! ... i get the "safari can't open the page because it can't find the server." message ....

    but these files are local files ....

    is there a trick that can be done?!"

    i found the problem .... http://localhost works when edge, wifi are active ... but not in offline mode ....127.0.0.1 works all the time ....

  17. #14
    "when in offline mode, i can't use safari! ... i get the "safari can't open the page because it can't find the server." message ....

    but these files are local files ....

    is there a trick that can be done?!"

    i found the problem .... http://localhost works when edge, wifi are active ... but not in offline mode ....127.0.0.1 works all the time ....

  18. #15
    Ok, I have everything setup as per the instructions here. When I go to 127.0.0.1 I just get a 'Hello Web' iPod. When I go to 127.0.0.1/.dirlist/ I can see the contents of the folder and if I try 127.0.0.1/.dirlist/dir-generator.php it says Errorrr. I can put PDFs into a folder called PDF inside of .dirlist/ and I can view them in Safari as intended but I am not getting the benefit of the .php and .css style sheet. What am I doing wrong?
    Last edited by 4nic8tor; 02-02-2008 at 04:13 PM.

  19. #16
    i had to play with some paths in httpd.conf to make it work!

    question: how can i hack the http address of the pdf i'm reading to make it open at a certain page?
    thanx!

  20. #17
    I modified .conf file as advised, but I still see the default lighttpd index page. How come? If I try to navigate manually to .dirlist, I get 404 error.

    What could go wrong?
    Later I'll attach my .conf file..it might be my bad editting.

  21. #18
    As promissed...

    Yesterday I upgraded to 1.1.3.

    Installed PHP and lighttpd, can access "hello web" index page.

    Created .dirlist folder and unpacked dirlist.zip content inside.

    Also modified lighttpd.conf as guided, but I guess that I did a bad job.

    Code:
    server.document-root = "/private/var/root/Sites/"
    # server.port = 80 # Default
    #server.bind = "127.0.0.1" # Default: All
    server.modules = ( "mod_cgi","mod_indexfile" )
    server.tag = "iPhone lighttpd"
    
    #server.pid-file            = "/var/run/lighttpd.pid"
    
    accesslog.filename = "/var/log/lighttpd/access.log"
    server.errorlog = "/var/log/lighttpd/error.log"
    
    index-file.names = ( "index.php", "index.py", "index.pl", "index.cgi", "index.html", "default.html", "/.dirlist/dir-generator.php" )
    url.access-deny = ( "~", ".inc" )
    static-file.exclude-extensions = ( ".php", ".pl", ".fcgi", ".cgi", ".py" )
    
    cgi.assign = ( ".pl"  => "/usr/bin/perl", ".py" => "/usr/bin/python", ".rb" => "/usr/local/bin/ruby", ".cgi" => "", ".sh" => "", ".php" => "/opt/iphone/bin/php-cgi" )
    
    mimetype.assign             = (
    	".pdf"          =>      "application/pdf",
    	".sig"          =>      "application/pgp-signature",
    	".spl"          =>      "application/futuresplash",
    	".class"        =>      "application/octet-stream",
    	".ps"           =>      "application/postscript",
    	".torrent"      =>      "application/x-bittorrent",
    	".dvi"          =>      "application/x-dvi",
    	".gz"           =>      "application/x-gzip",
    	".pac"          =>      "application/x-ns-proxy-autoconfig",
    	".swf"          =>      "application/x-shockwave-flash",
    	".tar.gz"       =>      "application/x-tgz",
    	".tgz"          =>      "application/x-tgz",
    	".tar"          =>      "application/x-tar",
    	".zip"          =>      "application/zip",
    	".mp3"          =>      "audio/mpeg",
    	".m3u"          =>      "audio/x-mpegurl",
    	".wma"          =>      "audio/x-ms-wma",
    	".wax"          =>      "audio/x-ms-wax",
    	".ogg"          =>      "application/ogg",
    	".wav"          =>      "audio/x-wav",
    	".gif"          =>      "image/gif",
    	".jpg"          =>      "image/jpeg",
    	".jpeg"         =>      "image/jpeg",
    	".png"          =>      "image/png",
    	".xbm"          =>      "image/x-xbitmap",
    	".xpm"          =>      "image/x-xpixmap",
    	".xwd"          =>      "image/x-xwindowdump",
    	".css"          =>      "text/css",
    	".html"         =>      "text/html",
    	".htm"          =>      "text/html",
    	".js"           =>      "text/javascript",
    	".asc"          =>      "text/plain",
    	".c"            =>      "text/plain",
    	".cpp"          =>      "text/plain",
    	".log"          =>      "text/plain",
    	".conf"         =>      "text/plain",
    	".text"         =>      "text/plain",
    	".txt"          =>      "text/plain",
    	".dtd"          =>      "text/xml",
    	".xml"          =>      "text/xml",
    	".mpeg"         =>      "video/mpeg",
    	".mpg"          =>      "video/mpeg",
    	".mov"          =>      "video/quicktime",
    	".qt"           =>      "video/quicktime",
    	".avi"          =>      "video/x-msvideo",
    	".asf"          =>      "video/x-ms-asf",
    	".asx"          =>      "video/x-ms-asf",
    	".wmv"          =>      "video/x-ms-wmv",
    	".bz2"          =>      "application/x-bzip",
    	".tbz"          =>      "application/x-bzip-compressed-tar",
    	".tar.bz2"      =>      "application/x-bzip-compressed-tar",
    	# default mime type
    	""              =>      "application/octet-stream",
    )
    Now I can navigate to ie. .pdf file I placed in root/Sites, but where it should be in order to have it listed (browse and click) and not to have to type it's name in addressbar?

    Thanks

  22. #19
    Today I returned to this, read forum bit more and found some other useful tips

    Ie, http://www.modmyi.com/forums/showpos...5&postcount=15

    dir-listing.activate = "enable"
    +
    "mod_dirlisting"

    I've also renamed .dirlist folder to .dirlist, as it was named :2dirlist for some reason (as Finder cannot add dot in the name, I used DiskOrder to rename dirlist to .dirlist, and then copied that folder to iPhone, but it's name got converted ) and reloaded 127.0.0.1 page and there it was..in its full colors

    I've opened a new thread with all modifications in one place.

    PDF/CHM/DOC/XLS/photo viewer - all-in-one Safari/Lighttpd based (complete instruct.)

    Resulting look...

    Last edited by -V-O-Y-A-G-E-R-; 03-06-2008 at 04:56 AM. Reason: Automerged Doublepost

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •