Phone gap ios app - show pdf file with print/email options - iphone

I have a requirement to do the following task.
Inside a Phonegap iOS app, the user wants to view a pdf file after clicking a link which will load the pdf from the remote server.
And also user needs print, email functions with this document viewer.
So far I have tried following options.
Exit from the app when user click on the link and try to load the pdf throught the Safari. This is not working because user has to relogin for viewing the application.
Check with child-browser plugin. But it does not provide the options like print/email.
It'll be really great if some one can help on this who has similar experience.
Thanks

Related

Open link in browser or open app

I have made an iphone app. The app calls the webpage and displays the content. Server side coding is in php. The problem is I have several links in the webpage. When I click on the link in the webpage it opens the entire page and I am no longer able to go back to where I was.
I tried iframe but not all the website support it like google, facebook. What I am looking is someway to open the link in browser or launch the another app, like the app of facebook. I have quite thoroughly searched for the solution without much luck.
Any pointers would be greatly appreciated.
Thanks
To implement navigation for UIWebView you can do the following: create two buttons, one for going forward in history and one for going back. And here is the code for that buttons you must include:
//For going forward
if (yourWebView.canGoForward)
{
yourWebView.goForward();
}
//For going back
if (yourWebView.canGoBack)
{
yourWebView.goBack();
}

How to take a screenshot of a website

I am building a web browser for iPhone in Xcode and the "home page" of my app is a speed dial page which provide 6 slots for users to add their favorite website. Each slot will then display a screenshot of the website. So what I want to do here is to grab the screenshot from the link input by users, for example, "http://www.google.com". Is it possible to do this with cocoa touch?
In case anyone want to have a similar function like this, I did find a way to do it but not sure whether it's the best way of doing it. Or maybe now there are libraries or plugins out there that provide this function already.
My solution
After users have entered a website url, you need to create a temporary UIWebView and load the url (do not make it visible to the users). After the UIWebView finished loading, you make the UIWebView visible and then take a screenshot, after that, make the UIWebView invisible again immediately (or simply destroy it). In this case, you will get the screenshot of that website and users won't notice what just happened.

How to execute javaScript with Quartz (CGPDF) iPhone SDK

I would like to know that is it possible to run the JavaScript with Quartz.
I have to create an application to open the password protected PDF. I also have user name and password for that PDF and when user want to open the PDF I send the username and password to server. All the validation will be happend on server then server returning me the JavaScript code in response, I have to run the same JavaScript code in my App to unlock the PDF. Is there any way to run the javaScript in my App So that I will be able to open the Password Protected PDF.
I have tried to open the same PDF in all Standered iPad PDF App like(GoodReader, PDF Reader and so on) but they are also failed to unlock the PDF.
When I open the Same PDF in Adobe Reader in my MAC machine it open successfully.
Thanks
There's currently (as of iOS4/5) no way to use Javascript inside a PDF. You can use javascript in a web view, and do your server checks there, then unlocking the pdf, but that's of course not as secure as doing it all in the pdf. Some crazy people even included a custom build of the JavaScriptCore, as the Apple Framework is not directly accessible in iOS.

Link to my app that opens in mail on the iPhone, or the PC desktop

I'm trying to email someone a link to my iPhone app in the app store.
I've tried Apple's app-link-maker.
I've tried many of the suggestions here (and elsewhere) to use http: or itms: or itms-app:.
Or to use itunes.apple.com or phobos.apple.com or ax.search or several others.
I can't seem to get ONE link that works in both situations:
1) The user might be reading his email on his PC at home.
2) The user might be reading his email on his iPhone.
Various tries will always fail in either 1 of the 2 situations, when the user clicks on the link in his email.
("Can't open iTunes." "Too many redirections." Or it incorrectly tries to open the music-store instead of the app-store. "Can't find that app." Wastes time opening a browser on the iPhone, only to close it, just to open the appStore.)
Is there some magic link that I'm missing?
This one is easy
Go to the app in itunes
when you are in app's description page click on the grey drop down button under the large icon
select 'copy link'
paste link into an email
Voila

Possible to open iPhone Safari and target a specific window?

I have an app that uses OAuth to authenticate, which means the user must be directed to the website to authorize the application. I prefer to make it obvious to the user that they are using a standard browser to authorize at the original site rather than just using a web view to show the content within my app. However, every time they are directed to Safari (via openURL), it launches a new Safari window and once Safari has 8 windows open, it simply fails to work at all.
I'm wondering if there is an equivalen to the "target" attribute of an anchor tag in html which would allow me to cause all openURL calls from my application to open in the same window.
There is other functionality that I can expose via the web application, creating a hybrid app between native iphone functionality and web app functionality in Safari, but if I have to launch a new window every time I switch between the app and Safari, it becomes unworkable. The Youtube app is obviously able to return the user to the previous page after showing a video, but that might well be a custom plugin in Safari for iphone. Also, while returning to the previous page is somewhat useful, sending them to a new URL in the existing window really opens up a lot of possiblities.
I'm pretty sure there is no way to pass a target parameter to openURL:.
What I noticed about Safari is that it won't open another tab if the page you are opening with openURL: is/was already open in Safari. It just reloads that page. This might sound trivial and not helpful but perhaps you could use it to your advantage if you can make your web application only use one page. Different views or states could be expressed with #anchor tags.
An example is http://m.flickr.com. Notice their URL structure? It goes http://m.flickr.com/#/home, http://m.flickr.com/#/explore/interesting/, http://m.flickr.com/#/search and so on. All of these are different web pages to the user but to Safari it's all the same page.
I found iOS 6.0.1 Safari will open the same tab with a simple hashtag, without the slashes. So with the above example http://m.flickr.com, openURL to http://m.flickr.com#someinfo opens to the same tab.
In your webpage, use window.location.hash to return the params. In the above example it will return #someinfo.