'Pdf Viewer download button not working as expected

I am trying to show pdf in iframe using dynamic form submit, that is working fine we see the pdf properly but now when any user wants to download it via clicking download but it is showing ".htm" file. Also when I do it outside iframe every thing working fine.

<iframe id="report" name="showreport" style="width: 100%;height: 100vh;border: 0;"></iframe>

to dynamically provide pdf to iframe we are creating dynamic form as below:

const mapForm = document.createElement('form');
mapForm.target = "showreport";
mapForm.method = 'POST';
mapForm.action = url;

const mapInput = document.createElement('input');
mapInput.type = 'text';
mapInput.name = 'user';
mapInput.value = 'Admin';

mapForm.appendChild(mapInput);
document.body.appendChild(mapForm);

// Just submit
mapForm.submit();

But when we hit download button it is shows "html" instead of "pdf".

enter image description here



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source