Edge 浏览器打印对话框功能中的文件名问题 (index.pdf)

问题描述 投票:0回答:1

在 Edge 浏览器中,我打开 iframe 的 src 中指定的文件,如下所示。但是,当尝试将其另存为 PDF 时,文件名在 Chrome 浏览器中正确显示,但在 Edge 浏览器中默认为“index.pdf”。

尽管我进行了尝试,但我仍无法更改此文件名。你能帮我一下吗?

`...

    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>

我希望 PDF 文件名能够正确显示在此处,就像在 Chrome 浏览器中一样。我尝试更改 iframe 标题和其他信息,但无法达到预期的结果。

enter image description here

javascript microsoft-edge printdialog
1个回答
0
投票

当 Opera 或 Chrome 等 Chromium 提供文件名来保存打印时,它来自页面标题(通常是来自包含 iFrame 的页面的 HTML

<title>

我们可以在打印过程中的开发人员检查中看到这一点。此处,Chrome 从 PDF 元数据中提取并用作 iFrame HTML

<title>FPDF Editor Outpur</title>
,如右侧和提供的文件名中所示。

enter image description here

Edge 的做法有所不同,因为它不使用 PDF 元数据,而只是使用自己的默认索引包装器。

<title>chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/edge_pdf/index.html</title>
因此,没有使用打印功能的任何其他标题,这就是提供的名称
index.pdf

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.