summaryrefslogtreecommitdiff
path: root/docs/modules/extend/examples/pdf-converter-custom-title-page.rb
blob: e0d23b9baf45a8105502765d4fcbb7d6eeadf45a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
class PDFConverterCustomTitlePage < (Asciidoctor::Converter.for 'pdf')
  register_for 'pdf'

  def ink_title_page doc
    move_cursor_to page_height * 0.75
    theme_font :title_page do
      stroke_horizontal_rule '2967B2', line_width: 1.5, line_style: :double
      move_down 10
      doctitle = doc.doctitle partition: true
      theme_font :title_page_title do
        ink_prose doctitle.main, align: :center, color: theme.base_font_color, line_height: 1, margin: 0
      end
      if (subtitle = doctitle.subtitle)
        theme_font :title_page_subtitle do
          move_down 10
          ink_prose subtitle, align: :center, margin: 0
          move_down 10
        end
      end
      stroke_horizontal_rule '2967B2', line_width: 1.5, line_style: :double
      move_cursor_to page_height * 0.5
      convert ::Asciidoctor::Block.new doc, :image,
        content_model: :empty,
        attributes: { 'target' => 'sample-logo.jpg', 'pdfwidth' => '1.5in', 'align' => 'center' },
        pinned: true
    end
  end
end