File: page_size.rb

package info (click to toggle)
ruby-prawn 2.4.0%2Bdfsg-1~
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 4,396 kB
  • sloc: ruby: 16,090; sh: 43; makefile: 20
file content (34 lines) | stat: -rw-r--r-- 1,163 bytes parent folder | download | duplicates (2)
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
29
30
31
32
33
34
# frozen_string_literal: true

# Prawn comes with support for most of the common page sizes so you'll only need
# to provide specific values if your intended format is not supported. To see a
# list with all supported sizes take a look at PDF::Core::PageGeometry
#
# # To define the size use <code>:page_size</code> when creating new documents
# and <code>:size</code> when starting new pages. The default page size for new
# documents is LETTER (612.00 x 792.00).
#
# You may also define the orientation of the page to be either portrait
# (default) or landscape. Use <code>:page_layout</code> when creating new
# documents and <code>:layout</code> when starting new pages.

require_relative '../example_helper'

filename = File.basename(__FILE__).gsub('.rb', '.pdf')
Prawn::Document.generate(
  filename,
  page_size: 'EXECUTIVE',
  page_layout: :landscape
) do
  text 'EXECUTIVE landscape page.'

  custom_size = [275, 326]

  ['A4', 'TABLOID', 'B7', custom_size].each do |size|
    start_new_page(size: size, layout: :portrait)
    text "#{size} portrait page."

    start_new_page(size: size, layout: :landscape)
    text "#{size} landscape page."
  end
end