How can I set the filename for base64 pdf in iframe?
<p>I have a report PDF in base64, I want to show the file embedded in the HTML page. To do this I use the iFrame and works, but the problem is that I can't set the name of the PDF so that when downloaded it will be saved with the name assigned.</p>

<p>Can I set the filename?, if yes, how can I do it?</p>

<p>this is my code:</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>var iFrameBlock = $("&lt;iframe&gt;").attr({
      "src": base64file_encode,
      "width": "100%",
      "height": "100%",
      "frameborder": "0"
});

$("#previewPDF").html(iFrameBlock);</code></pre>
</div>
</div>

The result:
<a href="https://i.stack.imgur.com/jL3ss.png" rel="noreferrer">Preview of PDF</a></p>

<p>And when I try download the file, the name to be saved is "download.pdf"
<a href="https://i.stack.imgur.com/YotAs.png" rel="noreferrer">Save dialog</a></p>

<p>I tried differents ways, but do not work either:</p>

<ol>
<li><p>Adding attribute <strong><em>download="filename.pdf"</em></strong>
<div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>   
   var iFrameBlock = $("&lt;iframe&gt;").attr({
      "src": base64file_encode,
      "width": "100%",
      "height": "100%",
      "frameborder": "0",
      "download": "filename.pdf"
   });
   
   </code></pre>
</div>
</div>
</p></li>
<li><p>I tried to change the value inside the iframe, but I could find the correct attribute and the Chrome denied the action. </p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>   
   var iframe = $("iframe")[0];
   var iframeDocument = iframe.contentDocument || iframe.contentWindow.document;
   //here I suppose is the label of the filename
   $(iframeDocument).find("viewer-pdf-toolbar");
   
   </code></pre>
</div>
</div>
</p></li>
</ol>

<p>However, I want prevent use any other library.</p>

<p>Thank you for your time</p>