Blazor - Open PDF File in new Tab - pdf

I would like to open a pdf document via a button. Is this possible in Blazor?
Thanks for your help

Please try this solution
This is your javascript function
function openFile(data) {
var link = this.document.createElement('a');
link.download = data.fileName;
link.href = data.url;
link.target ="_blank";
this.document.body.appendChild(link);
link.click();
this.document.body.removeChild(link);
}
This is your razor file, replace url with your pdf download url, clicking on button will open pdf in new browser tab
#inject IJSRuntime JS
<button #onclick=#(()=> JS.InvokeVoidAsync("openFile", new {fileName="anyfileName", url="http://anyurl.com"}))>Download PDF</button>

Use HTML?
Download:
<a href=#PdfURL download>Download</a>
or
Open in new tab:
Open
or
Open in current tab (i.e. Navigate to it) :
<a href=#PdfURL>Open</a>?

Related

Open office documents in AxWebBrowser control without file download dialog programmatically in vb.net

I am trying to open office files in AxWebBrowser control and i did it programmatically in vb.net. But during opening it shows file download dialog with open,save and cancel button so how can i setup it "Open" always instead clicking on it by mouse.
This happening because the Microsoft Web Browser control does not handle Office documents natively. What you have to do is load it in an ActiveX control within the webpage instead.
You could do something like this :
<script language="javascript">
function openDoc() {
var doc = new ActiveXObject("Word.Application");
doc.visible = true;
doc.Documents.Open("path.docx");
}
opeDoc();
</script>

I want to open a PDF file within the application in titanium studio

I have URL of PDF file and want to open within the application so that i can navigate back to application. I don't want to go to browser. Can anyone help?
Check this out:
iOS:
http://docs.appcelerator.com/titanium/3.0/#!/api/Titanium.UI.iOS.DocumentViewer
Android
http://developer.appcelerator.com/question/72361/open-pdf-file-on-android
Or you could try and show it in a webview:
var pdfViewer = Ti.UI.createWebView({
url: "url.pdf",
width:1000,
height:1000
});

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.

Magnific Popup onload calling a url

I have an static HTML page I want to pop up using Magnific Popup when the page loads. In the examples on the site he only shows clicking a link that has the url of the page. I don't want a link but just page load. How do I get the url to be called without a link? I have the onload figured out
$(window).load(function () {
$.magnificPopup.open({
type: 'ajax',
showCloseBtn: true
}, 0);
});
So for example I want test.html to show up in the popup onload. Not sure how this is done.
You can initialize the magnific popup with a DOM Element created by jQuery and then click it. For example:
$(function() {
$('<a href="test.html">').magnificPopup({
type: 'ajax'
}).click();
});
If you need the link appear in the page, then just use appendTo function after click.

open URL link inside webview in mobile browser in Titanium Appcelerator

I have a webview with HTML contents. And I have few links in that HTML content. when i clicked the link,corresponding webpage opens within my application. Can i open the webpage in mobile browser when i clicked a particular link?
I have tried using target="_blank" property within anchor tag,which doesn't works.
and also i have used "openURL" webview property, but fireEvent is not working properly.
my main js file;
var mywebview = Ti.UI.createWebview({
height : 'auto',
width : '100%',
html : '<!DOCTYPE html><html><body>Visit W3Schools.com!<br>Visit Google.com!</body></html>',
)};
In app.js;
Ti.App.addEventListener("openLink", function(e){
alert(e.linkUrl);
Ti.Platform.openURL(e.linkUrl);
});
Ti.App.fireEvent works for me in this form:
youatnotes.com
and in app.js:
Ti.App.addEventListener('ynOpenURL', function(e) {
Ti.Platform.openURL(e.url);
});
You could the URL of the webview in the event in order to open the link inside the WebView.