Module: VivlioStarter::CLI::PdfCommands

Defined in:
lib/vivlio_starter/cli/pdf.rb

Overview

================================================================

Module: PDF 生成・圧縮・表示ロジック

提供機能:

- execute_pdf: Vivliostyle CLI による PDF 生成
- execute_pdf_compress: Ghostscript による PDF 圧縮
- execute_open_pdf: macOS Preview.app で PDF を開く

Samovar CLI コマンドから純粋な Hash オプションを受け取る。

Defined Under Namespace

Classes: PdfCommandRunner, PdfCompressor, PdfOpener, PdfPagesExporter, PdfRasterizer, PrintPdfCommandRunner

Class Method Summary collapse

Class Method Details

.execute_open_pdf(options, path = nil) ⇒ void

This method returns an undefined value.

PDF を Preview.app で開く

Parameters:

  • options (Hash)

    オプション

    • :verbose [Boolean] 詳細ログ出力
  • path (String, nil) (defaults to: nil)

    開くPDFパス



72
73
74
# File 'lib/vivlio_starter/cli/pdf.rb', line 72

def execute_open_pdf(options, path = nil)
  PdfOpener.new(options, path).call
end

.execute_pdf(options, config_path:, output_path:) ⇒ Boolean

PDF 生成を実行する(パイプライン専用・P4 §3.2)

Parameters:

  • options (Hash)

    オプション

    • :verbose [Boolean] 詳細ログ出力
  • config_path (String)

    生成 config(-c で vivliostyle へ渡す)

  • output_path (String)

    config の output に対応する成否確認先

Returns:

  • (Boolean)

    ビルドが成功し出力ファイルまで生成できたか



33
34
35
# File 'lib/vivlio_starter/cli/pdf.rb', line 33

def execute_pdf(options, config_path:, output_path:)
  PdfCommandRunner.new(options, config_path:, output_path:).call
end

.execute_pdf_compress(options, input = nil, output = nil) ⇒ void

This method returns an undefined value.

PDF 圧縮を実行する

Parameters:

  • options (Hash)

    オプション

    • :verbose [Boolean] 詳細ログ出力
  • input (String, nil) (defaults to: nil)

    入力PDFパス

  • output (String, nil) (defaults to: nil)

    出力PDFパス



44
45
46
# File 'lib/vivlio_starter/cli/pdf.rb', line 44

def execute_pdf_compress(options, input = nil, output = nil)
  PdfCompressor.new(options, input, output).call
end

.execute_pdf_pages(options, input = nil) ⇒ Hash

PDF をページ単位の JPEG に切り出す

Parameters:

  • options (Hash)

    :dpi, :quality, :pages, :output, :verbose

  • input (String, nil) (defaults to: nil)

    入力 PDF パス

Returns:

  • (Hash)

    生成結果



53
54
55
# File 'lib/vivlio_starter/cli/pdf.rb', line 53

def execute_pdf_pages(options, input = nil)
  PdfPagesExporter.new(options, input).call
end

.execute_pdf_rasterize(options, input = nil) ⇒ Hash

PDF を JPEG 化して再結合し、Type3 フォントを含まないラスタライズ PDF を生成する

Parameters:

  • options (Hash)

    :dpi, :quality, :clean, :verbose

  • input (String, nil) (defaults to: nil)

    入力 PDF パス

Returns:

  • (Hash)

    生成結果



62
63
64
# File 'lib/vivlio_starter/cli/pdf.rb', line 62

def execute_pdf_rasterize(options, input = nil)
  PdfRasterizer.new(options, input).call
end

.execute_print_pdf(options, config_path:, output_path:) ⇒ Boolean

入稿用 PDF を生成する(--crop-marks --bleed 付き・パイプライン専用)

Parameters:

  • options (Hash)

    オプション

  • config_path (String)

    生成 config(-c で vivliostyle へ渡す)

  • output_path (String)

    config の output に対応する成否確認先

Returns:

  • (Boolean)

    ビルドが成功し出力ファイルまで生成できたか



82
83
84
# File 'lib/vivlio_starter/cli/pdf.rb', line 82

def execute_print_pdf(options, config_path:, output_path:)
  PrintPdfCommandRunner.new(options, config_path:, output_path:).call
end