LoginSignup
10
6

More than 3 years have passed since last update.

Rubyなし VSCode Asciidoc extensionsでPDFを生成

Last updated at Posted at 2019-12-12

Ruby要らない

VSCodeのAsciidoc ExtensionsでPDFを生成します。

下記のものは要らない。

  • Ruby
  • rbenv
  • Asciidoctor
  • Asciidoctor-pdf

VSCodeのAsciidoc extensionはAsciidoctor.jsを使ってプレビュー表示、PDF出力を行う。
Rubyなんて要らない。

環境

環境は下記のようになります。

  • Windows10 Pro x64 build 1909
  • Visual Studio Code v1.40.2
  • Asciidoc extensions v2.7.7
  • wkhtmltopdf 0.12.4.0

RubyなしでPDFを生成するにはwkhtmltopdfを使います。

設定方法

  1. wkhtmltopdfを取得
  2. Asciidoc extension > Manage > 拡張設定の構成
    • adoc00.png
    • adoc01.png
  3. ユーザーを選択
  4. Asciidoc: Use_asciidoctor_jsにチェックが入っていることを確認
  5. Asciidoc: Use_asciidoctor-pdfのチェックが外れていることを確認
  6. 最後のAsciidoc: Wkhtmltopdf_path に wkhtmltopdf.exeの場所を指定する。
    1. adoc02_LI.jpg

これだけでOK。

使い方

  1. VSCode内でAsciidocで書かれたテキストを選択
  2. コマンドパレット
  3. AsciiDoc: Export document as PDF を選択
    1. adoc04.png
  4. PDFを保存する場所を選択
    1. adoc05.png
  5. PDFが出力されます。 adoc06.png

wkhtmltopdfを指定せずに動かす

whtmltopdfをインストールして設定しない場合、
export時にwkhtmltopdfをダウンロードしてくれます。

  1. VSCode内でAsciidocで書かれたテキストを選択
  2. コマンドパレット
  3. AsciiDoc: Export document as PDF を選択
    1. adoc04.png
  4. This feature requires wkhtmltopdf. do you want to download? と出てくるので
    1. adoc07.png
  5. Downloadを選択
  6. Downloading wkhtmltopdf
    1. adoc08.png 
  7. PDFを保存する場所を選択
    1. adoc05.png
  8. PDFが出力されます。 adoc06.png

解説

設定でwkhtmltopdfが指定されていない場合は、
下記の場所に勝手にダウンロードされて展開されます。

  • Windowsの場合
    • %USERPROFILE%.vscode\extensions\joaompinto.asciidoctor-vscode-2.7.7\out\src\commands
  • Macの場合
    • /Users/ユーザー名/.vscode/extensions/joaompinto.asciidoctor-vscode-2.7.7/out/src/commands
  • Linuxの場合
    • 多分下記の場所
    • ~/.vscode/extensions/joaompinto.asciidoctor-vscode-2.7.7/out/src/commands

そこにDownloadされたwkhtmltopdfを使ってPDFに変換するようです。
extensionに埋め込まずにダウンロードするようになっているのは、wkhtmltopdfのライセンスがLGPLだからと思われます。

wkhtmltopdfを使うせいなのか生成されるPDFは少し味気ないものになっている。
asciidoctor-pdf.js が最近開発されているようです。
もしasciidoc extensionsに組み込めたら少しマシになるかもしれません。

10
6
1

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
10
6