50

次のコードを使用するpngと、iPython ノートブックで画像を表示できます。pdf画像を見る方法はありますか?必ずしも IPython.display を使用する必要はありません。ファイル内のpdf画像をiPythonノートブック出力セルに印刷する方法を探しています。

## This is for an `png` image
from IPython.display import Image

fig = Image(filename=('./temp/my_plot.png'))
fig

ありがとうございました。

4

4 に答える 4

68

ipython/jupyter ノートブック内に pdf-s を表示するには、使用できますIFrame

from IPython.display import IFrame
IFrame("./samples/simple3.pdf", width=600, height=300)

これがスクリーンショットです

ipython/jupyter ノートブックでの pdf プレビュー

于 2016-02-26T15:05:56.290 に答える
4

Rplots.pdf と呼ばれるマルチイメージ pdf を仮定します。

以下は、jupyter ノートブック セルで動作します。私が使用したインストールのために

pip install Wand

このコードはセルに貼り付けます

from wand.image import Image  

imageFromPdf = Image(filename='Rplots.pdf')  
pages = len(imageFromPdf.sequence)  

image = Image(  
  width=imageFromPdf.width,  
  height=imageFromPdf.height * pages  
)  
for i in range(pages):  
  image.composite(  
  imageFromPdf.sequence[i],  
  top=imageFromPdf.height * i,  
  left=0  
)  
image.format="png"  
image 
于 2016-02-24T03:14:03.667 に答える