【问题标题】:How to embed pdfs files in jupyter notebook on Github如何在 Github 上的 jupyter notebook 中嵌入 pdfs 文件
【发布时间】:2018-07-26 17:34:37
【问题描述】:

所以我上传到我在 Github 上的存储库中的 pdf 文件很少。现在我在与 github 上的 pdf 文件相同的目录中上传一个 jupyter notebook 文件,并希望在 jupyter notebook 中显示 pdf。

我使用以下方法将 pdf 嵌入到笔记本中。

from IPython.display import IFrame
IFrame("https://github.com/user/first.pdf", width=900, height=800)

现在,当我在本地笔记本电脑上执行此操作时,同样的事情也有效,我将 pdf 文件存储在一个目录中,并将其链接到笔记本电脑上的 jupyter notebook 文件。我也可以看到内联的pdf。

但是,当我在 Github 上做同样的事情时,它不会显示 pdf 并得到以下内容:

所以我不确定为什么它无法链接存储在 github 上同一存储库中的 pdf,并在它在我的本地系统上运行时显示它们

有什么帮助吗?

谢谢

【问题讨论】:

    标签: python pdf jupyter-notebook


    【解决方案1】:

    在 Github 的情况下,这是因为 X-Frame-Options 限制。

    见:iframe not rendering in ipython-notebook

    作为一种解决方法,您可以尝试使用 rawgit.com:

    示例:

    https://raw.githubusercontent.com/mozilla/pdf.js/raw/master/test/pdfs/S2.pdf(不起作用)

    https://rawgit.com/mozilla/pdf.js/master/test/pdfs/S2.pdf(有效)

    【讨论】:

    • Rawgit 不再工作了。尝试: - jsDelivr - GitHub 页面 - CodeSandbox - unpkg
    猜你喜欢
    • 2015-10-27
    • 2021-06-07
    • 2023-03-12
    • 2017-02-24
    • 2021-06-21
    • 2020-11-30
    • 2018-04-23
    • 1970-01-01
    • 2021-04-10
    相关资源
    最近更新 更多