Class: VivlioStarter::CLI::PdfCommands::PdfPagesExporter
- Inherits:
-
Object
- Object
- VivlioStarter::CLI::PdfCommands::PdfPagesExporter
- Defined in:
- lib/vivlio_starter/cli/pdf.rb
Overview
PDF をページごとの JPEG に切り出す
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(options, cli_input = nil, pdf_to_jpeg: ::VivlioStarter::Pdf::PdfToJpeg) ⇒ PdfPagesExporter
constructor
A new instance of PdfPagesExporter.
Constructor Details
#initialize(options, cli_input = nil, pdf_to_jpeg: ::VivlioStarter::Pdf::PdfToJpeg) ⇒ PdfPagesExporter
Returns a new instance of PdfPagesExporter.
313 314 315 316 317 |
# File 'lib/vivlio_starter/cli/pdf.rb', line 313 def initialize(, cli_input = nil, pdf_to_jpeg: ::VivlioStarter::Pdf::PdfToJpeg) @options = || {} @cli_input = cli_input @pdf_to_jpeg = pdf_to_jpeg end |
Instance Method Details
#call ⇒ Object
319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 |
# File 'lib/vivlio_starter/cli/pdf.rb', line 319 def call apply_verbose pdf_path = resolve_pdf_path ensure_input_exists!(pdf_path) ensure_pdf_pages_tools! output_dir = output_dir_for(pdf_path) Common.log_action("PDFをJPEG画像に切り出しています…(入力: #{pdf_path} → 出力: #{output_dir}/)") images = pdf_to_jpeg.convert( pdf_path, output_dir:, dpi: normalized_dpi, quality: normalized_quality, pages: [:pages] ) Common.log_result("#{images.size} ページを画像化しました(#{output_dir}/)", status: :success) { pdf_path:, output_dir:, images: } end |