在Javascript中,我需要从API(现在需要授权标头)获取PDF,然后在Iframe中显示该PDF。最下面的示例实际上是我的代码,其中liveViewBody是当API不需要授权标头时生成PDF所需的值[[API_URL]”的JSON字符串。在API中必须使用授权标头之前,底层代码一直在工作。
“ [API_URL]”以标题:Content-Type:“ application / pdf”流式传输PDF。
<form id="pdf-form" target="pdf-iframe" action="[API_URL]" method="post">
<input type="hidden" name='data' value={liveViewBody} />
</form>
<iframe id="pdf-iframe" name="pdf-iframe" type="application/pdf"></iframe>
我尝试过: