Parsing pdf to populate tableview - iphone

I am working on an app.The requirement is I need to populate the tableViewCells based on a pdf file.Like for example the headers of the table view will be a topic name from pdf and the contents will be the data inside the header.
I tried googling out but didn't find anything useful.Earlier I thought of parsing the pdf but this approach doesnot seems to be useful because i didn't find any pdf parser useful.
The last approach I thought is adding the contents in a plist file and parsing that plist,but i know this is not best way to do it.
So guys please suugest some better approach.
Thank you

Related

iPhone sdk how to retrieve the Table of Contents from PDF file?

I am using VFR reader to display my pdf's. I need to extract the Table of Contents on a button click and display it in a tableview then it should lead to the respective pages while tapping on each.I googled for this and got these links
Create a table of contents from a pdf file
http://mobile.tutsplus.com/tutorials/iphone/ios-sdk-adding-a-table-of-contents-to-an-ipad-reader/
And i came to know that, to get TOC we must use "CGPDFDocumentGetCatalog(pdf doc)". But in my reader that "CGPDFDocumentGetCatalog(pdf doc)" is not at all getting called. Now how can i extract my TOC from my pdf file? Kindly help me out of this. I am struggling on this for a week. Thanks in advance.
Unfortunately I think the two answers you refer to point to different implementation strategies, which are both possibly valid but are different.
The first question is what the PDF files you have and want to show in your app look like. There is no such thing as a predefined TOC object in a PDF file, there are simply different ways to emulate this. The two most common ways are:
A) Bookmarks, which are a way to add little pieces of text to a structured tree, where each piece of text points to a specific location in the PDF file. These bookmarks can be added in the design application or later (there are specific tools to do so) and they can implement whatever structure.
B) Your PDF file might contain something that looks like a classic TOC from a book, which is basically just text on the opening pages, optionally with hyperlinks to specific locations in the book.
The second link you refer to shows how to create user interface where you can show the TOC in. The remaining question then is to figure out what items you want to display in the TOC window. In this second link you point to, the solution presented is to provide hard-coded items specific to one specific book. Of course this approach is not very useful when you want to display just any book.
So the question you are left with is how to figure out what items to display and where they link to.
If you consider my possibility A) above: a PDF file with bookmarks, the answer could be relatively simple. Answer 1 you point to explains how to look at the different structures inside a PDF file - bookmarks are simply such a structure (Defined in section 12.3 of the PDF specification: http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/PDF32000_2008.pdf)
This means you could use the techniques shown there to walk the different objects in the PDF file, and find each bookmark. The bookmark will give you the text to display and the actual location in the PDF file that text should jump to when clicked.
If you consider my possibility B) above: a PDF file without bookmarks but a classic TOC, this will be much harder to solve. Such table of contents are simply text on one or more pages, optionally with hyperlinks. Of course you could try to find all text on these pages (if you can figure out on which page the TOC starts and ends), but you'd then also have to figure out where that item links to. If there are no hyperlinks involved, that would be a daunting task.
So your first question should be how generic you want to solve this problem. Do you know which PDF files you'll want to display? Can you devise a TOC for these files yourself (as in your solution 2)? If not, can you be sure all PDF files contain bookmarks? The answer to those questions will largely determine the rest of your strategy...

How to Load .ePub content in UIWebview with pagination

I want to show all the contents from .ePub file to UIWebview with pagination(horizontal scrolling). For that i need to find out total content size that,each chapter contains, page size..
I'm not at all clear about how/where should i start. I don't know how to use stringByEvaluatingJavaScriptFromString to call the methods. Where should i write the function definition which is called using stringByEvaluatingJavaScriptFromString. Please anyone give me a step by step procedure for UIWebview pagination. There may be same question but i didn't get any clear explanation.
Explain me Step by step JQuery procedure
Thanks in Advance.
You can find good example of parsing and displaying ePub here. It does not use JQuery, only javascript.

How can I make a PDF document containing a table of data on iPhone?

I need a way of creating a table of data in landscape mode. This table should be in PDF form, is this possible on iPhone? If so please can someone advise on how to do it? If not, what are my other options?
I believe following link would definitely help you to create table using drawLine method in a loop. You can simply modify the drawLine method and implement to draw table for you. Also the code is very Handy to use with a very customizable methods for PDF creation.
http://www.ioslearner.com/generate-pdf-programmatically-iphoneipad/
For more help you can refer previous post.
create your table in UIWebView and then follow this link to make pdf from UIWebView
http://coderchrismills.wordpress.com/2011/06/25/making-a-pdf-from-a-uiwebview/
Easiest is using HTML. You can do all the text processing in objective-C and display the table in a simple UIWebView. This also gives you great control over how it is going to look.

Using TabBar and separating XML data by category in iPhone?

I want to use TabBar and I'm going to use many different TableView.
What I want to do is, as soon as the main application instance is created,
* a big XML file should be loaded
* Create TableView instance for each category(which includes array to save XML data)
* Loop through XML data and add one by one to proper TableView's array
So after this process, all TableView instance have an array which contains XML data only belongs to its category.
But I can not find where to do this since I'm using TabView template from IB.
Should I do all that programmatically??
You have to make use for NSXMLParser for parsing the XML data and store te parsed data in a NSMutableArray. Alternatively you can also use touchXML. Check this
link for more details about touchXML. Hope this helps.

html code appears in my text view in RSS feed app

i got an rss feed app. All is working ok apart from the fact that in my "description" textView
(detail of the rss) the text appears in html!
any ideas in what is going on?
thanks!
i have found the solution using a wbview with loadHTMLString.
however i would like to ask what is the difference between these two rss feeds:
http://newsrss.bbc.co.uk/rss/sportonline_world_edition/front_page/rss.xml
and this for example:
http://feeds.feedburner.com/pitsirikos/uPfN
in the first one i can get the textview to display the contents as they should appear while in the second one i get html code in the textview!
my code remains the same in both cases...
The key difference between them is that the latter contains prefix tags
e.g. and
Do you use NSXMLParser or libxml2 ? are you doing a strcmp with the element name ?