2
1

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 1 year has passed since last update.

SVGファイルをPDFに一気に変換する

Last updated at Posted at 2023-01-20

複数のSVGファイルをPDFに変換するためにコマンドを紹介します。

今回はUbuntuで実行しました。ディレクトリ構造は以下です。svgディレクトリの中にあるSVGファイルをPDFに変換したものをpdfディレクトリの中に保存します。

├── svg
│   ├── image1.svg
│   ├── image2.svg
│   ├── image3.svg
│
├── pdf
|

librsvg インストール

変換にはlibrsvgを用いました。
Ubuntuでは

sudo apt-get install librsvg2-bin

MacではHomebrewでインストールできるようです。

brew install librsvg

rsvg-convertコマンド

rsvg-convertコマンドを次のように用いてinput.svgをoutput.pdfに変換できます。

rsvg-convert -f pdf -o output.pdf input.svg

複数のsvgファイルをpdfに変換

今回は次のようにxargsと組み合わせることで複数のsvgファイルをpdfに変換しました。

find ./svg -type f -name '*.svg' | xargs -I{} sh -c 'rsvg-convert -f pdf -o "./pdf/$(basename {} .svg).pdf" {}'
2
1
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
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?