Class: DynamicPDFApi::OutlineList

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_client/OutlineList.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeOutlineList

Returns a new instance of OutlineList.



8
9
10
# File 'lib/ruby_client/OutlineList.rb', line 8

def initialize
  @_out_lines = []
end

Instance Attribute Details

#_out_linesObject

Returns the value of attribute _out_lines.



45
46
47
# File 'lib/ruby_client/OutlineList.rb', line 45

def _out_lines
  @_out_lines
end

Instance Method Details

#add(text, input = nil, page_offset = 0, page_zoom = PageZoom::FIT_PAGE) ⇒ Object

Adds an Outline object to the outline list.

Parameters:

  • text (String)

    Text of the outline.

  • input (String) (defaults to: nil)

    |Input URL the action launches or any of the ImageInput, DlexInput, PdfInput or PageInput objects to create PDF or nil.

  • page_offset (int) (defaults to: 0)

    Page number to navigate.

  • page_zoom (PageZoom) (defaults to: PageZoom::FIT_PAGE)

    PageZoom to display the destination.

Returns:

  • Outline The Outline object that is created.



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/ruby_client/OutlineList.rb', line 22

def add(text, input = nil, page_offset = 0, page_zoom = PageZoom::FIT_PAGE)
  if input.nil?
    out_line = Outline.new(text)
    @_out_lines << out_line
    out_line
  elsif input.is_a?(String)
    out_line = Outline.new(text, UrlAction.new(input))
    @_out_lines << out_line
    out_line
  elsif input.is_a?(Object)
    link_to = GoToAction.new(input)
    link_to.page_offset = page_offset
    link_to.page_zoom = page_zoom
    out_line = Outline.new(text, link_to)
    @_out_lines << out_line
    out_line
  end
end

#add_pdf_outlines(pdf_input) ⇒ Object



41
42
43
# File 'lib/ruby_client/OutlineList.rb', line 41

def add_pdf_outlines(pdf_input)
  @_out_lines << Outline.new(pdf_input)
end

#to_json(_options = {}) ⇒ Object



47
48
49
50
51
52
53
54
55
# File 'lib/ruby_client/OutlineList.rb', line 47

def to_json(_options = {})
  json_array = []

  (0..(@_out_lines.length - 1)).each do |i|
    json_array << @_out_lines[i] unless @_out_lines[i].nil?
  end

  JSON.pretty_generate(json_array)
end