I am building cordova print plugin using EPSON epos iOS SDK, to use it with hybrid mobile apps( ionic framework based). The sdk provides methods for printing text and image. But I have to print HTML template using it. is there any way to do so?
like if I can prepare UIWebView object from the template and convert it into UIImage. I am new to iOS development so dont know any proper way of doing that.
You can render the UIWebView offscreen, and then capture its as a UIImage. the answers below might help you solve the problem. One problem you may face is that UIWebView doesn't loads unless you add it on a UIWindow, this window can be any UIWindow object, not necessarily the window you are displaying to user.
How to get ENTIRE image from UIWebView including offscreen content
Does iPhone/iPad UIWebView need to be active view to render?
How do I save the contents of a UIWebView as an image
Related
I'm developing an hybrid app for iOS using ionic/cordova. This app implements some typical webrtc features such as video calls and file transfers between two peers.
For this purpose I'm using cordova-plugin-iosrtc which exposes all W3C WebRTC APIs.
While RTCPeerConnection, getUserMedia and other Javascript WebRTC APIs implementations are pretty good, otherwise the video element to which streams are attached is substituted by a native UIView layer (see Usage).
This way you can't completely control via JS the pseudo-video element (that is UIView). For example it's not possible to resize the video, position it, change all its CSS properties and so on. UIView size and position are set at initial value of HTML video element.
Is there a workaround or an alternative to this limitation (opened as an issue) of iosrtc cordova plugin?
Yes, the video element is not an actual HTML DOM element displays the video, however the library mimics the CSS of the video element to the best of its ability (for dimensions and positioning).
You can still manipulate the video element using JavaScript, but you must call an iosrtc method to update the UIView afterwards Using:
iosrtc.refreshVideos()
More information can be found here: https://github.com/eface2face/cordova-plugin-iosrtc/blob/master/docs/iosrtc.md#iosrtcrefreshvideos
cordova plugin iosrtc is updated and fixed the issue according to https://github.com/eface2face/cordova-plugin-iosrtc/pull/179.
Update the plugin and it will solve the issue.
I've tried to figure out if the functionality I need is possible with a PhoneGap plugin and haven't found a clear answer.
I'd just like some clarification as far as if this is within the scope of a plugin.
The functionality would be...
Within the webview a user triggers a button.
A camera preview screen of custom size, not full
screen, pops up over the webview.
The preview shows view from front facing camera except it's
cropped to the custom size.
A video automatically starts recording for a set amount of time,
then stops.
Once the video stops recording the preview screen goes away and the
local path to the movie file is returned to a callback.
Is this all reasonable functionality for a phonegap plugin?
Yes, you can definitely implement that functionality as a Phonegap plugin.
Possible steps that you can take are the following:
- Write the native code of the functionality first (Note: You can call and start activities through Phonegap plugin).
- Create a layout (Maybe, something that will overlay the webview with transparent background).
- Use the File API of Phonegap to access the movie file you just captured.
Does video.js support Android WebView?
We use an Android app to put a tablet in Kiosk Mode in which our web app runs. However, webview video tag does not give us a image of the first frame, only the ugly widgets background.
A better question might be whether your WebView supports video.js. You need to configure the WebView to behave equivalently to a proper browser – HTML5 video definitely won't work without some tweaking. I've found this custom web view to work well (including with video.js):
https://code.google.com/p/html5webview/
I am working on an iPad app, which has a UIWebview, which in turn hosts an html5 document that is saved locally and is not downloaded from the internet.
I am handling the rotation changed event in obj c and doing the relevant UI changes for native iOS, I have another guy working on the html5 and he says that he is handling that event in CSS, my question is:
can an html5 document loading within a UIWebview in an iOS app know that a rotation occurred? or is the iOS layer supposed to alert ( or notify ) the HTML5 layer of that?
How do people handle this situation?
Thanks.
One possibility, is to execute javascript functions from iOS.
So for instance, on your view controller's didRotateFromInterfaceOrientation method, you could in turn call stringByEvaluatingJavaScriptFromString on the UIWebView. This question talks about how to do that (Calling Javascript using UIWebView).
As far as the rotation and handling in CSS, here is a blog entry describing #media queries (https://mislav.net/2010/04/targeted-css/). I haven't tried the orientation queries, but I have used the other queries to target specific devices and screen types (i.e. retina).
With the new iBooks Author tool, you can create e-books for the iPad. The format allows you to embed HTML widgets created with Dashcode. The resulting files can be distributed outside of the app store, similar, but probably easier (because it is just one file in a format Apple fully supports), than offline HTML5 web apps (which you have to install via Safari).
What features of HTML5 can be used in those Dashcode widgets? Is there for example DOM storage? Canvas? Location?
Regarding storage, tests made in preview mode on the iPad suggest that localStorage works. It is per book. You can save data in one HTML widget and read them in another HTML widget.
Regarding location, this blog post on "Location with iBooks Author" suggests that it is functional
I just built a test widget that uses flot to draw graphs into a canvas element, and then I inserted the widget into an iBook. When previewing the iBook on my iPad 1, the graph doesn't appear in the in-layout thumbnail, but when expanded to full screen, the graph displays beautifully.
So as far as canvas is concerned: it appears to be available, but apparently only when in full-screen interactive mode.
Update: Apparently the in-layout thumbnail is just an image of the widget, not the widget itself, which is why the graph (which requires executing code) does not display.
CSS Animations can be inserted into iBooks via the iBooks author widget support. Here is an example of us using Sencha Animator to add animations to iBooks Author.
I didn't get Canvas Code to execute on an iPad 1.
Update: no success on iPad 2 either.
(Edit: I was using the Processing.js library)
There is a github repo with a few demonstration HTML widgets that show how to use the interactive features.