1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Vivliostyle Coreを用いたHTML->PDFビューワー

Posted at

VivliostyleのCore APIを使ってHTMLから出力するPDF出力をプレビューするところまでやってみた。

見ての通りほとんどコードは書いていない。ただAPIを読み込んで、簡単なページナビゲーションをつけてみただけのサンプルだが、Vivliostyle CoreのAPIドキュメントだけでは苦労する方も多いだろうから(実際私はかなり苦労した)、公開することにした。

レポジトリをクローンしたらnpmのパッケージをインストールする。Viviostyle CoreはCDNで提供されていないようなので、組み込む必要がある。

% npm install @vivliostyle/core
% npm install ts-loader, typescript, webpack, webpack-cli --save-dev

必須ライブラリが揃ったらWebpack。コマンドはpackage.jsonに書いてある。

% npm run build

/dist/index.htmlでLive Serverを立ち上げればVivliostyleのビュワーが、/dist/publish.htmlを読み込んでPDFプレビューを表示してくれる。左右カーソルキーか、画面のクリックでページ送りする。
ちなみにfile:///では動かないので、何らかの方法でhttpサーバーを立ち上げてください。VS CodeならLive Serverが楽だと思います。

スクリーンショット 2025-03-11 23.26.18.png

1
0
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?