How to display a PDF (w/hyperlinks) in an iPhone app like GoodReader? - iphone

All I need to know is how to put a PDF page into a UIWebView, and then retrieve the URL value (into an NSString) of a link when clicked. Can somebody please offer their knowledge on this? Thanks in advance.

Most iPhone PDF viewers are using CGPDF to render the PDF content.
To implement features like hyperlinks (AFIK hyperlinks in PDF are done via a "link annotation" tag, but there may be some other way), the PDF viewer uses the CGPDF API to scan/parse the PDF content stream for a given page, pull out any data it is interested in, then implement support for that feature.
So for hyperlinks, a viewer may use CGPDF to render the page in a view. It would also use CGPDF to scan the page looking for link annotations, and pull out any attributes it needed (contents, destination, coordinates, etc.) It would implement a touch-handler for the view and any code to execute when a user tapped the hyperlink.

This is not possible if you render PDFs in UIWebView.

Related

Pdf Navigation from Table of contents

I am working on a flutter app which generates PDF files in flutter using pdf library.I need to create a pdf file which has a table of contents. They should be linked with the actual content and should navigate to their respective pages when clicked on it. I couldn't find any documentation online for doing this using the pdf library. The PDF is going to be written to a file so PDF Viewers in flutter are not useful for me either. Can someone please help me out
can we use html code with dart like <a tag or something for internal navigation in PDF?
You can use Anchor and Link widgets from pdf/widgets.dart for internal navigation inside the generated PDF.
Just create an Anchor on the page to which you want to navigate to. You need to provide a name parameter for it and it should be unique.
Anchor(name:'my_anchor', child: any_child_widget);
You can now refer to that anchor from another page using Link widget.
Link(destination:'my_anchor',child: any_child_widget);
You can enclose any child within the Anchor and Link widget.

Annotating text in UIWebView

I am writing a app that has a UIWebView that displays a HTML5 page. I want to annotate some text on the web page and save it in SQLite database. The annotated text must be changed to a specific color as a visual effect.
Any suggestions that how can I select and get the text back in Objective-C?
You have two choices:
Parse the HTML5 document by hand
Inject Javascript into the page and walk the document. See Search and highlight text in UIWebView

How to Searching String from PDF using iphone sdk?

I am trying to create a PDF Reader application allow user to search string from the PDF. The very simple idea for displaying the PDF in webView but I don't know whether I can perform search in the PDF displayed in UIWebView or not?
If this is possible then please provide me any good tutorial for this. If not then I am using CGPDFDocumentRef and other classes of CoreGraphics. I am done with displaying PDF on a UIView without having UIWebView. I am unable to Zoom yet but it is displaying. Now for searching I have used this tutorial. http://www.random-ideas.net/posts/42. I am able to search and getting a bool value for string is available or not. but I am not getting how to highlight search text in PDF.
Please help me if it is possible with any one, UIWebView or the way I am doing using CoreGraphics.
Thanks.

iPhone - view PDF like in iBooks

I have question about view for displaying multipage PDFs in my app. I have found solutions with webview but they lack ability to zoom and scroll between pages horizontally. Also found solutions using Quartz2D but the same problem as above.
Is there any way to present PDF like in iBooks? You can pinch-i/out zoom, list between pages horizontally. And also how to do taht with single PDF file, not split PDF to pages.
Thanks a lot.
Update: 04 Feb 2012
Check out this project, it's opensource and very well made:
Project:
http://www.vfr.org/
Source:
https://github.com/vfr/Reader
I can't give you the answer, but i can redirect you to a example project that is able to load and render a multipage pdf page by page.
To be honest this application it's manly on the iBook curl effect (forget it, it's a private API, no way) but inside there is a class that render on a view a pdf page, I'm sure that if you play a little with that code, CGAffineTransformMakeScale, CGAffineTransformMakeTranslation and touch control you will be able to obtain that effect.
Link to the project:
http://blog.steventroughtonsmith.com/2010/02/apples-ibooks-dynamic-page-curl.html
Checkout this sample code from Apple:
http://developer.apple.com/library/ios/samplecode/ZoomingPDFViewer/Introduction/Intro.html
It tells you how to efficiently display and zoom PDF documents.
For paging, see this link:
http://www.random-ideas.net/posts/42
Between the two of those you should be all set.

iphone xml parses text but no images or paragraph spacing

i am trying to parse an xml blog found here: http://www.feed43.com/1515171705611023.xml
it has pictures within the text. I am able to parse the headers, the content and the link of the individual posts.
I, however, cannot get it to parse the paragraph spacing links within the text or images. all three of these are EXTREMELY important.
I am using this: http://github.com/mwaterfall/MWFeedParser with very few changes. most them having to do with appearances and the actual feed loaded as well as using a scroll view for the detail view instead of the table view shown.
note: it didnt load these things before I made changes either.
Can anyone help me?
What you are looking for is an html renderer, not an xml parser. On iPhone, that is WebKit, which can be used through UIWebView.
Extract the html embedded in the rss formatted xml and place it in a UIWebView using loadHTMLString. Usually, the baseURL will be the same as the rss source, without the filename.