【问题标题】:Displaying pdf files without using external libraries在不使用外部库的情况下显示 pdf 文件
【发布时间】:2021-11-05 03:52:48
【问题描述】:

在我的 Angular 应用程序中,我在 html 模板中包含了以下 sn-p:

<embed src="../assets/AOK_T2DM.pdf" style="width: 100%;height: 500px" type="application/pdf">

如下所示:

当我点击打开时,pdf文件被下载。

我怎样才能简单地显示内容而不是下载它?

【问题讨论】:

    标签: html css angular typescript pdf


    【解决方案1】:

    &lt;iframe src="https://docs.google.com/viewer?url=https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf&amp;embedded=true" frameborder="0" height="600" width="100%"&gt;&lt;/iframe&gt;

    使用下面的代码

    <iframe src="https://docs.google.com/viewer?url=File_URL&embedded=true" frameborder="0" height="1100px" width="100%"></iframe>
    

    根据需要设置高度或将高度设置为 100% 并设置父 div 的高度。 检查并更新它是否有效。

    【讨论】:

    • 请在您的回答中提供更多详细信息。正如目前所写的那样,很难理解您的解决方案。
    • 谢谢,但这也是一样的;它只下载它但不显示pdf文件内容...&lt;iframe src="../assets/AOK_T2DM.pdf" frameborder="0" height="1100px" width="100%"&gt;&lt;/iframe&gt;
    • 在本地主机或实时编辑器预览中运行文件,它可能有效。
    • 请添加更多详细信息以扩展您的答案,例如工作代码或文档引用。
    • 你可以查看这篇文章来了解一下medium.com/@arya.bawanta/…
    猜你喜欢
    • 1970-01-01
    • 2023-03-22
    • 1970-01-01
    • 1970-01-01
    • 2017-11-09
    • 1970-01-01
    • 1970-01-01
    • 2014-12-23
    • 2013-01-12
    相关资源
    最近更新 更多