本文介绍: 【代码base64转PDF。

今天做皖事通的对接下载电子证照后发现回传的是base64,调试确认是个麻烦事,网上搜了一下没有base64转PDF的在线预览功能,只能自己写个调试工具了,以下是通过纯JS方式写的代码,可直接拿去使用

<html>
<head>
<title>base64转PDF</title>
</head>
<body>
<script>
var base64Data = "把你的base64字符串放在这里";

function showPdf(base64String) {
  const iframe = document.createElement("iframe");
iframe.style="width:1000px;height:1000px";
  iframe.src = `data:application/pdf;base64,${base64String}`;
  document.body.appendChild(iframe);
}
showPdf(base64Data);
</script>


</body>
</html>

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注