PDF Stream to File Preview

Sorry if this has been asked before, I couldn’t find anything relevant.
I have table on my page that when a row is clicked it calls a Server Connect which does a GET request, passing the ID to an API which returns a response with a pdf stream.

{
  "status": 200,
  "headers": {
    "content-type": "application/pdf",
    "content-length": "14027",
    "server": "nginx",
    "expires": "Fri, 11 Nov 2022 16:31:54 GMT",
    "cache-control": "max-age=0, no-cache, no-store",
    "pragma": "no-cache",
    "date": "Fri, 11 Nov 2022 16:31:54 GMT",
    "connection": "close"
  },
  "data": "%PDF-1.7\r%�������\r1 0 obj\n .......... and so on

How would I go about getting the PDF to preview on the page in an iframe?
Thanks in advance

I know this has been talked about recently, but I’ve come to another hurdle.
I have a Server Connect that retrieves an invoice and I want to at least be able to download the generated pdf. (NodeJS)

My Server Connect returns the following


Yesterday I created a a direct server connect route /downloadinvoice/:invoice to my action
and the following anchor button

<a href="#" class="btn" download="invoice.pdf" dmx-bind:href="'downloadinvoice/'+invoice">Download PDF</a>

This does indeed download a pdf
But won’t open

Screenshot 2022-12-16 at 07.41.52
If I open the pdf with a text editor I see the pdf data response.


Am I missing a step?

Thanks in advance.

Notice the very first character of what you see in the text editor is a ", and I bet in the end you’ll find another "

This means the PDF contents are being wrapped in a string, and you’re essentially downloading a JSON object containing the PDF file instead of the PDF file itself (this is just a technical explanation, you’re not required to understand it)

Unfortunately, I’m not familiar with Wappler’s download functionality, so I can’t really help you. But, check this topic, it might be the same issue:

Thanks @Apple,
That seems to allow the file to open (without the “”)
I just need to work out why the page is blank when opened :+1: