13
11

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Google ColaboratoryでHTML・PDFに変換する

Last updated at Posted at 2020-06-28

レポート作成などに便利なGoogle Colaboratoryですが,pdf出力・HTML出力等が出来ません。
わざわざローカルにjupyterNotebookの環境構築をするのもめんどくさいので,Colab上でHTMLに変換しちゃいます。

from google.colab import files
import re

uploaded = files.upload()

for fn in uploaded.keys():
  fn_s = re.escape(fn)
  output_fn = fn.split('.', 1)[0]+'.html'
  output_fn_s = re.escape(output_fn)
  !jupyter nbconvert --to html $fn_s
  files.download(output_fn)
  !rm $fn_s

PDFへの変換はめんどくさいので,HTMLに出力しブラウザの印刷機能をつかってPDFに出力するとレイアウトが整っておすすめです。

13
11
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
13
11

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?