How can I edit PDF files in an iOS application? - iphone

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.

Related

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)

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

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.

How can I output tables to a PDF file with the iPhone SDK?

I want to output a PDF using UIKit's PDF creation methods. I see plenty of information on the web about creating a graphic context in a PDF, but I want to create smart text tables whose cells the user can later copy and paste into other applications (Word, Excel, etc.). How do I do this?
Unfortunately, that's not trivial. I recommend you the libharu PDF library for iPhone as a good point to start from.

Drawing a PDF full of formatted text with images on the iPhone

Is it possible to create a page with formatted text that is stored in core data. The text would need to be displayed with paragraphs and a few images. I have already written the code to create a PDF with one line of text, but I am unsure of the pattern needed to layout the PDF in a nice document way. One of reasons is I had to write the code in C. The data that will be in the document is of course In core data. And I do not know what the best practice is for what I am trying to do.
Unless you have a particular need for PDF, the best practice is to use HTML and UIWebView. WebView is the primary formatted-text displayer for iPhone. iPhoneOS 3.2 added CoreText, which is another option if you have serious layout needs, but it generally isn't needed for simple formatted text and data.
The Text and Web Programming Guide includes a good discussion of your formatting and layout options. Generally UIWebView is still your best bet.
I am quite sure NSData (your c bytes) could be stored in NSManagedObject.
Even if not. Why don't store only metadata in CoreData? Is much more simpler for example: info needed to render the page wanted, etc.
I am not sure archiving the hole PDF in CoreData is a good approach.