I am currently working on an educational project where I would like to add some PDF reading functionality to an iPhone app. I know that it is possible to add a UIWebView and display the PDF there, however I would like to add the ability to show page number, 'next', 'previous' buttons etc. Is CGPDFDocument the direction that I should be headed or is there a better (ie more feature rich) library available? I have had a look around to try and find the capabilities of CGPDFDocument, but besides the API reference there is not much available.
Would it also be possible with this to annotate a pdf?
Thanks
JP
Here is a good (working) example of the CGPDF functions:
http://www.olivetoast.com/blog/2009/08/simple-uiscrollview-catiledlayer-pdf-example/
It uses a CATiledLayer + UIScrollView, this may not be appropriate for a reader of sorts, but it still shows you how to load and draw a PDF doc without UIWebView (which severely restricts your abilities).
Change the layer type back to a layer, add in page handling using CGPDFDocumentGetNumberOfPages and then CGPDFDocumentGetPage and you have a pretty good reader.
I don't know how to perform annotations, I suspect you would need your own data structure on top of the document.
Update: 04 Feb 2012
Check out this project, it's opensource and very well made.
I think it could be a great starting point for your PDF reader.
Project:
http://www.vfr.org/
Source:
https://github.com/vfr/Reader
There are PDF reader apps, do these not support annotations?
Another angle could be for the iPhone app to read/download pages (images) from the internet, where one could add basic annotations to that (image/layer based), these coordinates could be saved to a server. Those annotations could then be added programatically to a PDF on the server for download?
Related
On a start page I have to offer the most recent editeded versions for quick access. I have the requirement that the user not only sees the name of the document but also a mini-preview. In fact, these documents are always the same object view but with different data bound.
So I guess the question is: Is there a simple way to include a shrunk version of a view in a view?
The easiest would be to convert the rendered HTML to canvas, and display that. Google uses a similar technique for generating website previews.
There are various html2canvas script which you can use, for instance https://github.com/niklasvh/html2canvas
What I am trying to do is to load a webpage into in a UIWebView. The problem is that I need to do some preprocessing on the html before displaying it in the web view.
The UIWebview loadHTMLString is quiet slow when the html is big. I don't need to display the full page therefore i am trying to remove some html nodes before displaying it in the web view to speed up the loading time.
I don't think using regex for that is a wise idea. I checked out NSXMLParser and TFHPPLE but I couldn't find any way to remove nodes from the html tree using an XPath or something.
I know I could do that using Javascript but that won't solve my problem. I also don't have no control on the website so I can't edit in the webpage itself.
Is there something as easy as deleteNodeUsingXPath or something :)
Cheers and thanks a lot for your help in advance.
One possibility solution: do a proxy website which strips out unwanted stuff. The iphone accesses the proxy website URL. The proxy website loads from the original website, strips out unwanted stuff, and replies with the remaining stuff.
There is a tool called Objective-C-HTML-Parser that will do what you are looking for. The documentation is thorough, and the implementation is pretty straight-forward.
Basically, you take your HTML string and make an HTMLParser object that you can then manipulate however you want. It is a very powerful library that basically lets you do whatever you want with HTML with easy-to-use Objective-C APIs.
Good luck!
With the iOS support for Quartz 2D and its support for the PDF format; should adding a signature image to a pdf be a little easier. I have looked all over and saw people are using the PDFKit, UIView or Core Graphic Library. Which is the easiest and the recommended library for the effort? Also, are there simple examples of the recommend library. When I tried to see how Quartz 2D worked, all I could find are narrative explanations about how it worked and specific method you may use but no complete examples. You know the hello world one. Anyway, I am new to iOS development but been writing code for over 20 years so I might be able to pick this OS up as well.
Can some poor soul have pity on me and please point me in the right direction?
I have done this by loading the old pdf file on view and then add signature on that view and then render the view. check the following post
Add a signature image to a pdf without showing the pdf data to user in iOS
But not able create the pdf which contain existing pdf with signature "without showing on view" .
It's too late to answer this question now. But let me just provide some pointers for people who may bump into this question in future.
This one summarizes PDF handling in iOS pretty well. Good for starters.
http://www.ioslearner.com/generate-pdf-programmatically-iphoneipad/#more-242
This one is also similar, but not very exhaustive. http://www.absoluteripple.com/1/post/2012/03/generating-pdf-in-ios.html
The above links do not talk about handling existing PDFs. I found this stackoverflow answer really useful for that.
Add pdf page to an existing pdf objective-c
Just a note, if you want manipulate existing PDFs, Quartz 2d is the way to go.
Also look at reference pages of CGPDFDocument, CGPDFPage, CGPDFContext and CGContext.
I'm looking to create a small reference app. It has a UItabBar and 4 views that each load a UITableView which can be drilled down to display, essentially a page of information and pictures, like a book.
If I want to make the page a little more stylised than just using labels and image views, the common consensus seems to be to create HTML pages and load them in a web view.
Being new to this, please could someone give me some direction on where to even begin with this? As I understand it, I essentially need to develop a web page with a text editor, and then what? Actualy upload online and create a public website? It's a little confusing, and as I'm not a developer, a little disheartening to think I'll now have to learn HTML as well as Obj-C to create a simple app.
I'm sure there are some great tools or alternatives out there and if someone could recommend such avenues I'd be incredibly grateful.
Kind regards,
Ryan
If you want to display HTML pages in a UIWebView you can store them in your bundle and display them from there (so no need to put the pages online). It is best though to stick with the UI controls that Apple provides you with. If you need more customization try subclassing some of the standard controls.
If you customize your UI too much it will just confuse the user and degrade their experience.
I'm looking for a good vector library for displaying animated graphics on the iPhone. Something that could possibly display SVG. Anyone have any ideas or insights?
Quartz, i.e. the vector graphics library that's already built into the phone. Depending on the requirements, you could write a parser for the parts of the SVG spec you actually plan on using. For example perhaps your application only requires the Tiny SVG spec.
Sorry that this answer doesn't point to a framework that already exists, but depending on how badly you really need it, it might make sense to roll your own or a start an open source project (especially since this is the kind of project people would probably be quite happy to contribute to).
GCDrawKit is an outstanding vector illustration framework, but it does not have native support for SVG yet and is built around AppKit, so it's not iPhone compatible. It also is not geared towards animation.
WebKit provides native support for SVG on the Mac, and even lets you manipulate the DOM to modify or save SVG, but I don't believe you're given enough access to it on the iPhone to do the same there.
Your best bet is to write a parser for SVG XML (it isn't too difficult a format), use Quartz for drawing, and back it up with Core Animation for the animated elements.
WebKit
libsvg
Cairo
github.com/SVGKit/SVGKit - almost-but-not-quite standards compliant SVG lib on iOS. (FYI i'm one of the maintainers).
UIWebView works great for SVG.
Just drop it in you app in IB, load a file into it and you are set.
You can then call JavaScript from ObjC, very useful for manipulation.
I just answered another cocoa-touch SVG question: Drawing vector graphics on iphone
but my general suggestion was to look at GitHub for answers (Objective-c & SVG Search)
https://github.com/search?type=Everything&language=objective-c&q=SVG