首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >如何在HTML当前页面下载PDF文件?

如何在HTML当前页面下载PDF文件?
EN

Stack Overflow用户
提问于 2018-07-20 08:15:27
回答 1查看 0关注 0票数 0

在页面中当我输入代码时会自动创建一个PDF文件,同时在另一页面(.php)上显示。我不想在按下按钮时,PDF文件会在另一页面上显示,只想下载而不显示。请问有什么方法?

Button样式:https://i.stack.imgur.com/B93l1.png

<div class="form-group" align="right">
 <center><input type="submit" id="btn_rfc" value="Validar" target="_blank" class="btn btn-primary" autocomplete="off" style="background-color: #3155B9; font-size: 20px; border-radius: 30px;" /></center></div>

PDF文件(打开一个新页面来显示它)

<?php
session_start();
if (isset($_SESSION['login'])) {

}else{
    header("Location: ../../index.php");
}

require '../lib/nusoap.php';

$cliente = new nusoap_client('.....php');

require '../clases/conexion.php';
$mysql = new Conexion;
$mysql->conectar();
$mysql->SeleccionarDB("db");
$colsult = "select rfc from businesses where subdomain='".$_SESSION['login']."'";
$mysql->GetExecuteSql($colsult);
foreach ($mysql->result as $empre) {
    $rfcEmpre = $empre['rfc'];
}

mysql_close($mysql->conexion);

$param = array('rfc' => $rfcEmpre);

$consult = $client->call('List',$param);

..

EN

回答 1

Stack Overflow用户

发布于 2018-07-20 17:29:12

你可以尝试将该按钮装入href标记中并链接到要下载的pdf。

<!DOCTYPE html>

<html>

<body>

<p>Click on the w3schools logo to download the image:<p>

<a href="/images/myw3schoolsimage.jpg" download>

<img border="0" src="/images/myw3schoolsimage.jpg" alt="W3Schools" width="104" height="142">

</a>

<p><b>Note:</b> The download attribute is not supported in Edge version 12, IE, Safari 10 (and earlier), or Opera version 12 (and earlier).</p>

</body>

</html>

如果你想下载的文件还没有创建(因为你在单击的同时创建了该文件)。我不知道你如何处理pdf的创建,所以抱歉我不能对此有所帮助。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/-100005609

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档