gpt4 book ai didi

php - 使用 anchor 标记提交表单以在新窗口中打开 pdf

转载 作者:搜寻专家 更新时间:2023-10-31 22:06:33 25 4
gpt4 key购买 nike

我有一个 JQM 站点,它在提交表单时生成一个 pdf 文件。一切正常,但我有一个问题,当从 iPhone 的主屏幕启动时,pdf 无法在新窗口中打开(打开 safari..)。
看来我不是唯一遇到此问题的人,但我还没有找到可行的解决方案。如果我链接到带有 anchor 标记的静态 pdf,我在 safari 中打开一个新窗口没有问题。我的结论是,如果我提交带有 anchor 标签的表单,一切都会有效..!但是,当我尝试使用以下代码时,结果与我使用常规提交按钮发布表单时的结果相同。

任何人都可以帮我解决另一个问题吗?或者也许调整它以使其起作用?

这是我的表格:

 <form name="pdf" action="pdf_report1.php" data-ajax="false" target="_blank" id="pdf_report" method="POST">

<input type="hidden" name="customer_id" value="<?php echo $customer_id; ?>" >
<input type="hidden" name="date_from" value="<?php echo $date_from; ?>" >
<input type="hidden" name="date_to" value="<?php echo $date_to; ?>" >
<input type="hidden" name="user_id" value="<?php echo $user_id; ?>" >
<input type="hidden" name="maskin_id" value="<?php echo $maskin_id; ?>" >
<input type="hidden" name="akeri_id" value="<?php echo $akeri_id; ?>" >
<input type="hidden" name="littra_id" value="<?php echo $littra_id; ?>" >
<a href="javascript: document.getElementById('pdf_report').submit();" data-role="button">Create PDF</a>

</form>

最佳答案

确保将这些行放入 pdf_report1.php

header('Content-type: application/pdf');
header('Content-Disposition: attachment; filename="downloaded.pdf"');

关于php - 使用 anchor 标记提交表单以在新窗口中打开 pdf,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17620916/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com