Examples and/or 3RD Party Libraries to Optimize Display of PDFs on iPad - iphone

I have read numerous posts here (and experienced first hand) some of the limitations of using UIWebView to display PDF files on iPad/iPhone.
Are there any 3rd party libraries that handle PDF page rendering/caching/optimization? Don't need to handle adding annotations or markups to the PDF; just want to minimize delays in opening the document and moving between pages in PDFs.
Thanks.

Instead of using UIWebView use CoreGraphics. The best library I have seen for implementing PDF's with this is the Leaves library.
You will need to get familiar with the CGPDF calls and if you are not experienced with CoreGraphics it can be a bit tricky at first but the framework I suggested makes things pretty simple to get started and do basic things like displaying a local document or document on a server.

Related

Copying images in from anti-scraper websites. Google Docs handles it easily - anyone know how?

I've been playing around with making a draftjs plugin that lets the user paste in mixed text&image content from websites and have images auto-uploaded to the server. I've quickly come to the realization that it's not easy, simply because of how many different sites use different kinds of counter-measures for copy/pasting images. Standard image tags in page content are no problem - easily grab the src and handle the file upload from the url. However, many sites use all kinds of trickery to make this a pain. For example, some will only serve small thumbnails, requiring a GET request on the image with a hash key in order to retrieve a larger version. Others somehow seem to corrupt the image so that it's unreadable by the time it's been retrieved. Others still play with weird embed tags to mess with draftjs' image blocks.
But then I open up a Google Docs file, and find that when I copy any images into that from a website, there's never any troubles whatsoever. All the problematic websites that I'm finding myself having to write specific methods for retrieving from seem to be handled by Google Docs with ease.
Am I using completely the wrong approach by trying to retrieve images from a url? Does Google use a far superior approach (yes, I presume) - in which case, does anyone have any idea what that approach might be?

Is there a way to convert epub format to images?

I need a tool to programmatically convert epub files to a series of images. The output should look like screenshots taken on a canonical device (for this application, an iPad). I haven't been able to find any tools that do something like this.
So what I'd really like (1) is a tool that does that. But assuming that I'm correct that no such tool exists, is there (2) a library (preferably a Perl module, but I'm not that picky) that will read and render ePub?
Obviously, rolling my own I could combine tools for unzipping, reading html, reading xml, putting everything in the right order, and rendering html within certain constraints. Though I'd rather not do that, and if that's the only option I'll have to go on to look for a tool that will do the last part of that or I'll have to create that too.
Any leads on (1), or failing that (2)?
Apologies if what I'm about to type is just crazy-talk on my part--in fact, I'm pretty sure it is--but perhaps something like this might work and I'm kind of interested in knowing how well it might work for you:
Use Frank (https://github.com/moredip/Frank) to control the iOS Simulator on a Mac. Program it to open up the EPUB docs you need.
All you need then is something to automate the taking of the screen shots. Obviously, these will look like the EPUBs are being rendered in an iPad (or an iPhone if you wish--the iOS Simulator does both, of course).
Automating the screenshots can probably be done with AppleScript, although the hard part might be getting it to talk to Frank. Worst case, you can tell Frank to pause for 5 seconds after it loads each page and tell AppleScript to take a screen shot every five seconds. That sucks, but if you're desperate, it will get it done. It's also possible Frank can somehow make the screenshots happen--I haven't used it enough to know.
Pandoc can convert from EPub to LaTeX (and therefore to PDF) or to any number of other formats. Conceptually this should be a type (1) solution.
depends on your definition of "look like" - do you want the user-chrome or just the epub rendering for a given screen size.
I would check out the various epub readers for your platform of choice, size the window to your preferred dimensions, and then just "print" the epub to a virtual printer that outputs to image files - on windoze I use imageprint.
You could easily make a "frame" from an iPad product shot and place your screenshots within that - only thing missing would be as I said the user chrome.

interactive pdf on the iOS

I have been looking for a way to present an interactive pdf file (created by in-design) on
the iPhone. I read a bunch of questions here but none says how to do it. The pdf file contain the text and in the middle it contains a 3d module, but when I present it on the iPhone it shows only the text and an empty white box where the module should appear.
Is it even possible to do it?
I'll be glad for any assistant on this subject or even where to look.
Thanks in advance,
Shahar.
Apple's PDF parser does not support 3D stuff. You're better of implementing the 3D part yourself and just adding that as a UIView on top of the PDF. There are several PDF frameworks that help with that (see https://stackoverflow.com/questions/3801358/pdf-parsing-library-for-ios)
Another alternative might be licensing Adobe's iOS rendering engine. But I doubt that they already added 3D support (or that they will be). Also, from what my sources tell me, pricing is rather high and apparently the framework not very developer friendly. (But I haven't used it myself)

How can I edit PDF files in an iOS application?

In my iPhone / iPad application, I show a person's medical reports in the form of a PDF. I have saved the reports in the documents directory and am reading them from there.
I want the user to be able to add or edit comments on these PDFs, as well as be able to highlight certain sections in the PDF. After editing, the application should be able to save the PDF back into the documents directory.
Is this possible within an iOS application? If so, how? Is this a task for Core Graphics?
Editing PDF directly on iPad/iPhone is a rather big job because the standard API only supports showing it (and only a bit more.) If you want to do anything more, you need to invest a huge amount of time to implement generic pdf handling code.
There is an open-source library handling these, e.g. this one. I don't know if it fits your needs, though.
A better idea, in my opinion, is to create a native UI showing the data contained in the PDF file using the standard Cocoa-Touch UIKit and create the PDF once the user is done with it so that the user can export it back. That way, you don't have to write a complicated PDF handling code.
In any case, it's not a good idea to show generic PDF on iPhone, because the screen size is so small (iPad is a different question, especially if you expect the user to be familiar with the particular format of your pdf.). A dedicated UI would be much better.

iPhone RSS Reader -- parseXML won't Load some XML feeds

I am using the SIMPLE RSS reading example found at http://theappleblog.com/2008/08/04/tutorial-build-a-simple-rss-reader-for-iphone/
It uses parseXML to load the RSS feeds.
Here is the problem I am having. For the following RSS feed example, I am having trouble getting it to load the feed. Comes up with an error that it cannot connect. However on my Mac RSS Reader it works fine, so I know the link is good.
Any ideas on why it cannot load this particular feed but it can load others fine?
http://www.okstate.com/rss.dbml?db_oem_id=200&media=news
Thanks.
I've just released an open source RSS/Atom Parser for iPhone and hopefully it might be of some use.
I'd love to hear your thoughts on it too!
In my experience, HTML markup causes an RSS parser to fail in most cases. I've experienced a problem like this with a lot of parser classes I've come across (in search of the ultimate one, which I didn't find)
My guess is that entities such as
's
are responsible for your crash. That was usually the case with my crashes. This also lead to my decision to create a 'proxy server' to pre-parse the XML before sending it to the iPhone (which gives me the advantage of caching, scaling, and some other stuff). I do believe there are solid solutions out there, but is always difficult writing a parser for so many RSS implementations.
P.S: W3C validates this feed as 'valid', so it really is 'our' problem..
Your problem could lie with:
Unicode characters (i.e. I see some o's with two dots above them in the feed)
The code you have doesn't respect CDATA sections correctly
To find out which is the case, save the feed file to your local disk and load it via your code to make sure the error happens.
Do a binary search on the file to find out if a particular RSS entry is causing the problem (i.e. remove all but the first rss entry and see if the problem exists. If it does, then the problem is there, if it doesn't put half the rss entries back in the file and repeat)
I've been experiencing a similar issue. I haven't yet pinned down the answer, but I've noticed that RSS 2 tends to parse more successfully than the rest.
There are many RSS feeds that contain invalid XML, usually because they were hacked together on the server side using HTML templates by somebody who didn't understand XML. I've seen improperly escaped (or non-escaped) HTML post contents, missing close tags, badly nested tags, and so on.
If you want to be able to parse arbitrary feeds, you have to clean up bad XML. The usual way is to use the "htmlTidy" library, which is included in the OS. This can clean up XML as well as HTML.
This example you're following uses NSXMLParser -- I have no idea why. It's a lower-level API and it doesn't support tidying. I would suggest using NSXMLDocument instead. There's a flag in that API that will tell it to use tidy when parsing the XML. This API also returns you the XML as a handy tree of elements that's easy to work with.