Class: VivlioStarter::Pdf::StandardProvider
- Inherits:
-
Object
- Object
- VivlioStarter::Pdf::StandardProvider
- Defined in:
- lib/vivlio_starter/cli/pdf/standard_provider.rb
Overview
MITライセンス互換の標準プロバイダ
隠しノンブルの合成は本体(Build::NombreStamper: Prawn + qpdf --overlay)へ移設したため、 プロバイダの責務は「ページ数取得・空白ページ生成・アウトライン付与」に縮小した。 拡張プラグイン(vivlio-starter-pdf / HexaPDF)が担うのはアウトライン付与のみ。
Instance Method Summary collapse
-
#add_outline!(_original_pdf_path, _items, max_level:) ⇒ Boolean
PDF アウトラインを付与する (Standard モードではスキップ).
-
#ensure_blank_page_pdf(path, width_pt, height_pt) ⇒ String
空白ページのPDFを生成する.
-
#page_count(pdf_path) ⇒ Integer?
PDF のページ数を取得する.
Instance Method Details
#add_outline!(_original_pdf_path, _items, max_level:) ⇒ Boolean
PDF アウトラインを付与する (Standard モードではスキップ)
43 44 45 46 47 |
# File 'lib/vivlio_starter/cli/pdf/standard_provider.rb', line 43 def add_outline!(_original_pdf_path, _items, max_level:) # rubocop:disable Lint/UnusedMethodArgument CLI::Common.log_warn('PDF しおり(アウトライン)の付与は Standard モード(MIT) ではサポートされていません。') CLI::Common.log_info(' => 拡張機能が必要な場合は `gem install vivlio-starter-pdf` を検討してください。') false end |
#ensure_blank_page_pdf(path, width_pt, height_pt) ⇒ String
空白ページのPDFを生成する
31 32 33 34 35 36 |
# File 'lib/vivlio_starter/cli/pdf/standard_provider.rb', line 31 def ensure_blank_page_pdf(path, width_pt, height_pt) return path if File.exist?(path) Prawn::Document.generate(path, page_size: [width_pt, height_pt]) {} path end |
#page_count(pdf_path) ⇒ Integer?
PDF のページ数を取得する
18 19 20 21 22 23 24 |
# File 'lib/vivlio_starter/cli/pdf/standard_provider.rb', line 18 def page_count(pdf_path) return nil unless File.exist?(pdf_path) ::PDF::Reader.new(pdf_path).page_count rescue StandardError nil end |