qgis / qwc2-demo-app

QWC2 demo application
Other
240 stars 149 forks source link

Wrong save format using inlinePrintOutput on chromium based browsers #504

Closed cazitouni closed 7 months ago

cazitouni commented 7 months ago

Using the inlinePrintOutput function to display the Atlas as a .pdf in the iframe works well, but there's an issue when attempting to save it using Edge/Chrome. It prompts to save it as an xml/json instead of a .pdf.

This functionality performs well on Firefox. Eliminating the targeting to the iframe in the form and opening it in a new tab displays the correct .pdf format when saving. Hence, it doesn't seem to be a content-type problem.

What might be a viable solution to this issue? Perhaps returning the Axios result used for non-inlinePrintOutput to the iframe instead of using the form's target option could be a potential solution. I can look into it eventually

Thank you in advance. Best regards, Clément.

manisandro commented 7 months ago

This is an annoying (and actually pretty broken) behavior of some browsers, which re-download the PDF when clicking the save button, but they request the URL as GET when pressing the save button, meaning the request parameters submitted via POST are lost and hence the QGIS Server will return an invalid request XML. Happy to have any solutions for this...

manisandro commented 7 months ago

See https://bugs.chromium.org/p/chromium/issues/detail?id=69677 and https://bugs.chromium.org/p/chromium/issues/detail?id=158957

cazitouni commented 7 months ago

@manisandro, I've found something, here , commit on my branch. It's working good for downloading the file, only problem is that the file gets a random name, not the project one's.

I don't know if it looks like a good solution but it seems to works on my machine. I can look more into it.

let me know your opinion,

Kind regards, Clément,

manisandro commented 7 months ago

Interesting! In my view this solution is already much better than the currently broken behaviour. Happy to accept a PR

cazitouni commented 7 months ago

Nice, I'll look a bit more into it tommorow for file name and I make the PR.

I'll let you know.

Thanks.