Download PDF file directly from external URL - pdf

I'm wondering if it's possible to download the PDF directly from another website's URL rather than opening a new window.
<button>Download FILE</button>

The most recommended way would be something like this
<!DOCTYPE html>
<html>
<body>
<h3>https://www.w3schools.com/TAGS/tryit.asp?filename=tryhtml5_a_download</h3>
<p>Click on the image to download PDF32000_2008.pdf<p>
<a href="https://opensource.adobe.com/dc-acrobat-sdk-docs/standards/pdfstandards/pdf/PDF32000_2008.pdf" download><img src="https://www.w3schools.com/images/myw3schoolsimage.jpg" alt="PDF32000_2008 standard" width="104" height="142">
</a>
<p><b>Note:</b> The download attribute is not supported in IE or Edge (prior version 18), or in Safari (prior version 10.1).</p>
</body>
</html>
That is preferable to your method in that it lets the user decide the time of the download and rename document! Also you only need to serve a cover icon or image. HOWEVER although this works without any problems for me as a client user "offweb" it may not work same as any other link on a server if it is cross site tainted. The href address should only be for resources served on or via your own site.
and that should also be the case even if you use iFrame or any other hyper download method, without addressing Cross Origin issues.
Hence something like your current method is often touted as a "workaround" to bypass any Cross Site limitation, since the call for a fresh tab is a direct link from client browser to remote source thus not via "person in the middle" again HOWEVER, you should improve security by adding to it:-
<button>Download FILE</button>
<!DOCTYPE html>
<html>
<body>
<h3>https://www.w3schools.com/TAGS/tryit.asp?filename=tryhtml5_a_download</h3>
<p>Click on the image to download PDF32000_2008.pdf<p>
<a href="https://opensource.adobe.com/dc-acrobat-sdk-docs/standards/pdfstandards/pdf/PDF32000_2008.pdf" rel="noopener noreferrer" target="_blank"><img src="https://www.w3schools.com/images/myw3schoolsimage.jpg" alt="PDF32000_2008 standard" width="104" height="142">
</a>
<p><b>Note:</b> The download attribute is not supported in IE or Edge (prior version 18), or in Safari (prior version 10.1).</p>
</body>
</html>
Note the snippet above was update to latest Adobe location and works as a file but here on Stack Overflow your browser may block the call !
The linked page gains partial access to the linking page via the window.opener object:- see https://stackoverflow.com/a/45902400/10802527 and https://www.jitbit.com/alexblog/256-targetblank---the-most-underestimated-vulnerability-ever/

Related

Programmatically retrieving the contents of the chrome://gpu url

I am trying to programmatically retrieve the contents of the chrome://gpu url.
As a start I tried to load up chrome://gpu from the command-line, but chromium refuses to start up with a url that is prefixed with a chrome: prefix.
Then I tried to out-clever that limitation by using a redirect page:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="refresh" content="7; url='chrome://gpu'" />
</head>
<body>
<p>Please follow this link.</p>
</body>
</html>
But that page, although it can be launched from command line, would not refresh for me.
Even clicking the link does not work, which leads me to determine that you cannot link to chrome://gpu at all.
When I tried right-click open-in-tab on the link, I get:
Which means that chromium is actively blocking access to it, unless it is typed out by the user.
I have two questions:
Can this block be disabled?
If not, how can I retrieve this information programmatically? Can I somehow feed artificial keystrokes into chromium?
Update 1
Tried to add virtual key-strokes with:
$ wtype test
Compositor does not support the virtual keyboard protocol
Update 2
I have gotten further: I can use ydotool to make chromium browse to chrome://gpu and then do Save-As, but that saves a nearly empty html page that references a gpu_internals.js script.
Is it possible to save the output of that script instead?
Access to the "chrome://gpu" URL is restricted and cannot be directly accessed programmatically. This restriction is in place to prevent malicious actors from manipulating the internal settings of the browser.
An alternative approach could be to use a headless browser like Puppeteer or Selenium to automate the process of retrieving the information from the "chrome://gpu" page.
I've found ydotool to be a good solution for this.
With it, you can automatically open a page to chrome://gpu and then click in the browser window, followed by Ctrl+A, Ctrl+C to retrieve to contents to the clipboard.
You can then use wl-paste from the wl-clipboard package to get it.

Displaying TVHeadend stream in a browser

I am trying to display a TVHeadend stream in the browser as a pre-cursor to get this running on my TV. So I whipped up this sample HTML code where 192.168.0.4 is my server running TVHeadend and the channel UUID is 3df2b09783d8afeb8a323f5025431df7:
<html>
<body>
<video width="720" height="567" autoplay="true" controls>
<source src="http://192.168.0.4:9981/stream/channel/3df2b09783d8afeb8a323f5025431df7?profile=webtv-h264-aac-matroska" type="video/webm">
Your browser does not support the video tag.
</video>
</body>
</html>
Whether I show the HTML page locally on my computer or served via a local Apache webserver, the result is always the same: I get an emtpy video player control. The network tab does not show any errors, neither does the console. It does bring a warning however:
"Empty src!"
However the src is clearly not empty.
When I copy the src URL to my browser (Chrome) and call it, it starts downloading the stream (instead of showing it, but that might be expected). Why does the video control not seem to be able to show the video?
Do I have any other debug options I can check out? This problem has bugged me for a while now and I have tried to drill down to the source of it by removing the TV SDK and all other side code just to see if the actual video will play (which it does not).
At first I thought it might've been an authorization issue but then why does Chrome seem to be able to download the stream just fine? I have logged on to TVHeadend in the same browser (in a different tab) to make sure that a missing logon is not in the way of things.
I have also tried putting : in between the "http://" and the IP address to pass the parameters required for basic auth - but to no avail.
Does somebody have any hints as to what might be the roadblock here?

stream RTSP to HTML website

I would like to display IP cameras streaming in RTSP into a web page.
I've tried many solutions, like using VLC to transcode the stream, but none of them seems to be reliable enough to create a real web service.
I'm thinking on using some media server like flussonic or Red5. But I don't know if it will work.
This is why I would like to know what is the best (and the simple) solution to display RTSP streams on a webpage.
...to create a real web service.
I've been looking for an answer for the past two or three days (I need support on as many browsers as possible, and latency as low as possible, so WebRTC was the way to go (is there anything better?)) and I've finally found it.
Check out this repo.
From the repo's readme + the additional steps I had to take (on Ubuntu 18.04) to make this work:
Install go
$ sudo snap install go --classic
Get the code on your local device (Could someone enlighten me on what the export is for?).
$ export GO111MODULE=on
$ go get github.com/deepch/RTSPtoWebRTC
This step didn't work for me, so I just downloaded the code in a .zip file and extracted it in the given directory and proceeded. (What did I miss? The src directory was not there before I made it)
$ cd ~/go/src/github.com/deepch/RTSPtoWebRTC
Run from current directory.
$ go run .
Then I opened the link below a web browser ( I tested on Chrome, iOS Safari, but it also works on Firefox).
http://127.0.0.1:8083
This took me very little time to implement. Big thanks to the guys making this. All the other stuff I've found is either 5-7 years old and not working or non-WebRTC or a marketed paid service asking for unreasonable amounts of money.
I hope I answered your question.
After tried the "plugins" way suggested in
How can I display an RTSP video stream in a web page?
And the "conversion" way suggested in
https://www.npmjs.com/package/html5_rtsp_player
I finally found a really straight forward solution using this plugin, works for Chrome only which is ok for my project.
https://www.videoexpertsgroup.com/vxg-chrome-plugin/
This is how the html code look like
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="utf-8" />
<script type="text/javascript" src="/assets/vxgplayer-1.8.31/vxgplayer-1.8.31.min.js"></script>
<link href="/assets/vxgplayer-1.8.31/vxgplayer-1.8.31.min.css" rel="stylesheet" />
</head>
<body>
<div class="vxgplayer"
id="vxg_media_player1"
width="640"
height="480"
url="rtsp://admin:admin#192.168.1.117/defaultPrimary0?streamtype=u"
nmf-src="/assets/vxgplayer-1.8.31/pnacl/Release/media_player.nmf"
nmf-path="media_player.nmf"
useragent-prefix="MMP/3.0"
latency="10000"
autohide="2"
volume="0.7"
avsync
autostart
controls
mute
aspect-ratio
aspect-ratio-mode="1"
auto-reconnect
connection-timeout="5000"
connection-udp="0"
custom-digital-zoom></div>
</body>
</html>
You can integrate VLC library into your website and VLC will take care of everything you need for playing RTSP stream:
https://wiki.videolan.org/index.php?title=HowTo_Integrate_VLC_plugin_in_your_webpage&action=edit&oldid=19150

How to test the google +1 button local

I am just creating an html file to test out the google +1 button. I guess the problem my html is not deployed on a server. How can you test the google+1 button on your local machine. This code doesn't render anything.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Google+1</title>
<!-- <link rel="stylesheet" href="css/main.css" type="text/css" /> -->
<script type=”text/javascript” src=”http://apis.google.com/js/plusone.js”></script>
</head>
<body >
<g:plusone></g:plusone>
</body>
</html>
I assume it can't be done because Google's API check the source of the request, otherwise many security holes would be exist.
Why won't you check it online? Just upload the site to it's domain and try to +1 from your account.
Another option for design purposes only: download an image of the +1 button and use it in the offline version.
You're probably just opening the HTML file locally. You can run the Google+ widgets on your local machine and will need to have internet access to load the external scripts. What you need to do is start up a web server and open the file from there. This is due to permissions for JavaScript required from the +1 code.
If you are on a Mac, you can do this either through the built-in Apache server (copy the file to /Library/WebServer/Documents and navigate to localhost/filename.html) or by spinning up a Python web server in the same folder as the file with the following command:
python -m SimpleHTTPServer 8000
After starting the Python web server, you can navigate to localhost port 8000.
If you are running on a Windows PC, you can find a number of web servers and install them, WAMP is a pretty simple option. Again, you would just install WAMP and then put your HTML file in the web/www folder that WAMP created and navigate there from localhost. You can also install Python and use the built-in web server as mentioned before.

Using Google Webfonts in Windows Phone 8 web browser control

I am trying to use web fonts in my Windows phone application. From the comments I have read, I understood that it is not possible to use fonts embedded into XAP file. So, I am trying to open a webpage that contains Google Web Fonts which is at: http://omercelik.com/e.htm
When I open this page from Internet Explorer on phone, it shows the font correctly. But when I try to load this page from a webBrowser control, it doesn't loads this page. I don't do anything else but this on my app:
private void PhoneApplicationPage_Loaded_1(object sender, RoutedEventArgs e)
{
webBrowser.Navigate(new Uri("http://omercelik.com/e.htm"));
}
So, still no success to show custom fonts in my application. There are suggestions to host font remotely and cache but even without caching, I couldn't show fonts. Can someone provide a working example of this?
It is possible to embed truetype fonts in Windows Phone 8 webapps by setting the embeddable tag on the font to 0 using software like TTFEdit. This might prove a more reliable and elegant solution to your problem.
See my answer to another Stack Overflow question here for all the details.
When using the WebBrowser control, it's very important to include the HTML doctype if you want to get proper IE10 behaviour (ie. not quirks mode) in Windows Phone 8...
<!DOCTYPE html>
<html>
<head>
<style>
#import url(http://fonts.googleapis.com/css?family=Tangerine);
</style>
</head>
<body>
<div id="para" style="font-family:'Tangerine', serif;">Making the Web Beautiful</div>
</body>
</html>
For future reference, Windows Phone 7's WebBrowser control (based on IE9) does not support Web Fonts.