Opening pdf files with the Trigger.io in-app browser? - pdf

I have a hybrid mobile app built on Trigger.io that opens links (some of them are user generated content) in the in-app child browser (forge.tabs module) per default. When trying to open a .pdf document the screen will stay blank white (tested on both Android and iOS).
Here is a cut down version of the code I'm using:
$(document).on('click', 'a', function() {
window.forge.tabs.open( $(this).attr('href') );
return false;
});
I would expect to either view the document in the in-app browser or be able to download it to the device.

Assuming your PDFs are local, you'll need to do a "getURL" first.
Here's a function that works just fine for me:
function showPDF (pdfName) {
forge.tools.getURL(pdfName, function (myPDF ) { forge.tabs.open(myPDF); });
}
Then just call showPDF with a relative or absolute url i.e.
<button class="btn" type="button" onclick="showPDF('assets/pdf/sample.pdf');">

Related

Not able to open PDF url using DocumentViewer ionic 4

I have a pdf URL and I want to open it using DocumentViewer. When I run code:
this._document.viewDocument(pdfUrl, 'application/pdf', options);
It is not opening PDF. I tried downloading PDF to my mobile and then open it. Please find code below:
transfer.download(downloadUrl, filename).then(entry => {
const url = entry.toURL();
if (this._plt.is('ios')) {
this._document.viewDocument(pdfUrl, 'application/pdf', options);
} else {
this._fileOpener.open(pdfUrl, 'application/pdf')
.then(() => console.log('File is opened'))
.catch(e => this.presentAlert('Error opening file', e));
}
});
I have tables and images in my PDF. When I ran above code I am not able to see HTML5 tables in the PDF.
I need help on how to open up PDF URL directly using DocumentViewer.
NOTE: I have seen a couple of post on StackOverflow suggesting to use InAppBrowser. I have a requirement where I need to display it as PDF.
I have read in https://github.com/sitewaerts/cordova-plugin-document-viewer,
that in android : Due to license restrictions in muPDF, the plugin dispatches to a separate (free) viewer app based on muPDF. If the viewer app is not yet installed, the user may be redirected to the google play app store.
https://play.google.com/store/apps/details?id=de.sitewaerts.cleverdox.viewer.
you may use other pdf plugins like
https://github.com/vadimdez/ng2-pdf-viewer/
hope this helps

Worklight 6.1: How to add EULA to hybrid app

Environment:
Worklight 6.1.0.2
dojo 1.9.4
We have created a hybrid app using Worklight 6.1 for android, iOS and windows8 platform. Now we would like to add and show End User License Agreement (EULA) window to the user, when the app first time launch. It should have Accept and Decline button. If user tap on Accept button, then he should be able to use the app.
I would like to know, how can we achieve this using Worklight 6.1.
Any help on this, will be much appreciated.
FYI there is nothing specific here to Worklight.
You could implement this in any number of ways w/out ever using any Worklight API whatsoever.
You could achieve it for example like this (untested code - you'll need to experiment):
In main.js create some global variable eulaAccepted:
var eulaAccepted;
// You will need to handle this property using HTML5 Local Storage so that it will persist for the next time the app is launched, and have the app act accordingly.
Then, in wlCommonInit():
function wlCommonInit() {
if (!eulaAccepted) {
displayEula();
} else {
displayApp();
}
}
In displayEula():
function displayEula() {
// either display a dialog using `WL.SimpleDialog`...
// Or maybe custom HTML with "accept" and "not accept" buttons
WL.SimpleDialog.show(
"Eula Agreement", "your-eula-text-here",
[{text: "Accept", handler: acceptEula },
{text: "Reject", handler: rejectEula}]
);
}
Handle the result:
function acceptEula() {
eulaAccepted = true;
... // Some code that will store the `eulaAccepted` variable using HTML5 Local Storage API
displayApp();
}
function rejectEula() {
// Display some other custom HTML instead of your app.
// Maybe also additional logic to try again to accept the Eula...
}

Worklight WL.TabBar does not display correct titles on iOS

I downloaded the IncludeExternalPages project from the getting started site. In the main.js for iPhone I can see what the WL.TabBar should display:
function wlEnvInit(){
wlCommonInit();
WL.TabBar.init();
WL.TabBar.addItem("WLtab1", function () {tabClicked(1); } ,"Home",{
image: "tabButton:Favorites"
});
WL.TabBar.addItem("WLtab2", function () {tabClicked(2); } ,"Client",{
image: "tabButton:Search"
});
WL.TabBar.addItem("WLtab3", function () {tabClicked(3); } ,"IBM",{
image: "tabButton:More"
});
WL.TabBar.setVisible(true);
WL.TabBar.setSelectedItem("WLtab1");
tabClicked(1);
}
However, when executing this code in a simulator the labels are Favorite, Search, and More instead of Home, Client, and IBM. I made no modifications to the project, just built it and ran on the iOS simulator. This was using WL6.2 with the 9/4 update (latest).
Any ideas why the titles are defaulting to iOS instead of what is specified in the code?
When using the "built-in" OS icons (Favorites, More, Search, ...) the tab item's title will default to that of the icon instead of the label in the code.
To change that, provide your own Favorites icon, for example, and then the "Home" label will be used.

How to open url in default browser using titanium in Blackberry

I am currently working on a project in titanium .I wish to open url in default browser of BB10
simulator instead of webview used in the app on click event .I am using the following code
var win =Ti.UI.createWindow({
title:'Test'
});
var webview=Ti.UI.createWebView({
url:"http://demo.php.otssolutions.com/videoapp-uat/home"
});
win.add(webview);
webview.addEventListener('click',function(e){
var url=e.url;
Ti.API.info(url);
Titanium.Platform.openURL("http://demo.php.otssolutions.com/videoapp-uat/home");
});
win.open();
Thanks in advance for any help

open url in default OS browser

Is there a way to open URL in default OS browser?
I have MenuItem and want to open certain URL whenever user clicks this item:
var item = new gui.MenuItem({
label: 'Shortcut',
click: function(){
//here i want OS to open some URL
}
});
You can proceed like that:
gui.Shell.openExternal("http://website.com")
See the documentation here: https://github.com/rogerwang/node-webkit/wiki/Shell
See also How to open a browser window from a node-webkit app? for more informations.