1

In the Edge browser, I am opening the file specified in the src of an iframe as shown below. However, when trying to save it as a PDF, the file name appears correctly in the Chrome browser, but in the Edge browser, it defaults to "index.pdf."

Despite my attempts, I haven't been able to change this file name. Could you please assist me?

`...

    var objFra = document.getElementById(iframeName);

    if (isChrome || isOpera) {
        objFra.contentWindow.focus();
        objFra.contentWindow.print();
    }
    else if (isEdge || isInternetExplorer || isFirefox) {
        objFra.onload = function () {
            objFra.contentWindow.focus();
            objFra.contentWindow.print();
            return;
        }
        if (isEdge) {
            window.setTimeout(printDocument, 100);
        }
    ...}`

<iframe src="../../File/TEMP/e42c2279-1363-4d87-933f-625ff20eec7d/ExampleDocument.pdf#zoom=100&amp;toolbar=0" class="m-3" style="height: 95% !important; width: 99%" frameborder="0" id="iDoc" name="iDoc"></iframe>

I expect the PDF file name to appear correctly here, just as it does in the Chrome browser. I tried changing the iframe title and other information, but I couldn't achieve the desired result.

enter image description here

4
  • Do you have any source indicating that the file name cannot be changed in the Edge browser? Commented Oct 25, 2024 at 12:55
  • Do you have any sample code that you could send me to test? Commented Oct 25, 2024 at 12:57
  • I'm using an iframe, so there seem to be some points that don't align with the example you provided. I tried changing the title of the iframe, but it didn't have any effect. Commented Oct 25, 2024 at 13:25
  • That is not an index either. Commented Oct 25, 2024 at 14:01

1 Answer 1

1

When Chromiums like Opera or Chrome etc offer a filename to save a print it is sourced from the Page Title (usually the HTML <title> from a page holding an iFrame)

enter image description here

We can see that in the Developer inspection during print. Here the <title> has been extracted by Chrome from the PDF Metadata and used as the iFrame HTML <title>FPDF Editor Outpur</title> seen on the right and in the offered filename.

enter image description here

Edge does it different as it does not use the PDF Metadata but simply its own default index wrapper. <title>chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/edge_pdf/index.html</title> hence without any other title using print function, that is the offered name index.pdf.

enter image description here

There are other browsers apart from Chromium's and Mozilla's that may have other print defaults such as no default name.

enter image description here

However most Mozilla Fox based PDF viewers like R3D will simply use PDF.js viewer.pdf

enter image description here

Sign up to request clarification or add additional context in comments.

3 Comments

Thank you for your help, but it seems that the situation is a bit different in ASP.NET. Although I provided a title, it didn’t appear. I gave your comment an upvote, but unfortunately, I still can't solve the issue.
I am changing the title of the main page, the iframe’s title, and the contentDocument’s title within the iframe, but unfortunately, it’s not yielding any results. I can’t figure out where it's pulling this index from.
I found that 'index.pdf' is coming from the title as you mentioned, but I don’t know how to modify it because this is a popup opened by the Edge browser.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.