26
Views
3
Comments
Download widget for tablette and PWA
Question

Hi,

I'm trying to convert a HTML page into pdf, but the issua I xant download the result because I dont see the download widget in the left menu.


is there a solution for this problem please ?

2021-03-08 09-24-09
Rúben Meireles

Hi,

I suggest you take a look at OutSystems File Transfer Plugin that now supports PWA:

https://www.outsystems.com/forge/component-overview/1409/file-transfer-plugin

 Cheers,

Rúben

2019-09-30 07-35-56
Aurelio Junior

Hello,

Since you're building a PWA, your options are a bit limited. However, here's one way to implement this:

1 - Expose a REST API method in your app that will generate and return the PDF file. Something like this:

Notice that there's a call to the "AddHeader" action from the "HTTPRequestHandler" extension:

2 - In your UI's client action, you'll have to use JavaScript to make a request to your API and download the resulting file:

You have to pass the full URL to the REST API method you created above to the "DocumentURL" input parameter.

Here's the full JavaScript code:

var xhr = new XMLHttpRequest();
xhr.open('GET', $parameters.DocumentURL, true);
xhr.responseType = 'blob';
xhr.onload = function(e) {
    if (this.status == 200) {
        var myBlob = this.response;
        var link = document.createElement('a');
        link.href = window.URL.createObjectURL(myBlob);
        link.download = "Document.pdf";
        link.click();
    }};
xhr.send();

I tested this in a PWA running in iOS and it worked well. I do not have an Android device to test it though.

2024-11-05 11-28-22
Sunil Rajput
Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.