dynamicpdf_api 1.0.0.pre.beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/lib/ruby_client/Action.rb +15 -0
- data/lib/ruby_client/AdditionalResource.rb +113 -0
- data/lib/ruby_client/AdditionalResourceType.rb +27 -0
- data/lib/ruby_client/Aes128Security.rb +70 -0
- data/lib/ruby_client/Aes256Security.rb +70 -0
- data/lib/ruby_client/Align.rb +21 -0
- data/lib/ruby_client/ButtonFieldInformation.rb +48 -0
- data/lib/ruby_client/ButtonFieldType.rb +16 -0
- data/lib/ruby_client/ChoiceFieldInformation.rb +52 -0
- data/lib/ruby_client/ChoiceFieldType.rb +16 -0
- data/lib/ruby_client/CmykColor.rb +47 -0
- data/lib/ruby_client/Color.rb +12 -0
- data/lib/ruby_client/ColorSpaceType.rb +36 -0
- data/lib/ruby_client/ConverterInput.rb +100 -0
- data/lib/ruby_client/DlexInput.rb +61 -0
- data/lib/ruby_client/DlexLayout.rb +135 -0
- data/lib/ruby_client/DlexResource.rb +40 -0
- data/lib/ruby_client/Elements/AztecBarcodeElement.rb +113 -0
- data/lib/ruby_client/Elements/AztecSymbolSize.rb +206 -0
- data/lib/ruby_client/Elements/BarcodeElement.rb +37 -0
- data/lib/ruby_client/Elements/Code11BarcodeElement.rb +77 -0
- data/lib/ruby_client/Elements/Code128BarcodeElement.rb +105 -0
- data/lib/ruby_client/Elements/Code25BarcodeElement.rb +75 -0
- data/lib/ruby_client/Elements/Code39BarcodeElement.rb +75 -0
- data/lib/ruby_client/Elements/Code93BarcodeElement.rb +75 -0
- data/lib/ruby_client/Elements/Compaction.rb +26 -0
- data/lib/ruby_client/Elements/DataMatrixBarcodeElement.rb +95 -0
- data/lib/ruby_client/Elements/DataMatrixEncodingType.rb +56 -0
- data/lib/ruby_client/Elements/DataMatrixFunctionCharacter.rb +31 -0
- data/lib/ruby_client/Elements/DataMatrixSymbolSize.rb +161 -0
- data/lib/ruby_client/Elements/Dim2BarcodeElement.rb +28 -0
- data/lib/ruby_client/Elements/Element.rb +46 -0
- data/lib/ruby_client/Elements/ElementPlacement.rb +36 -0
- data/lib/ruby_client/Elements/ElementType.rb +96 -0
- data/lib/ruby_client/Elements/ErrorCorrection.rb +56 -0
- data/lib/ruby_client/Elements/Gs1DataBarBarcodeElement.rb +76 -0
- data/lib/ruby_client/Elements/Gs1DataBarType.rb +22 -0
- data/lib/ruby_client/Elements/Iata25BarcodeElement.rb +83 -0
- data/lib/ruby_client/Elements/ImageElement.rb +108 -0
- data/lib/ruby_client/Elements/LineElement.rb +92 -0
- data/lib/ruby_client/Elements/MsiBarcodeCheckDigitMode.rb +31 -0
- data/lib/ruby_client/Elements/MsiBarcodeElement.rb +79 -0
- data/lib/ruby_client/Elements/PageNumberingElement.rb +91 -0
- data/lib/ruby_client/Elements/Pdf417BarcodeElement.rb +112 -0
- data/lib/ruby_client/Elements/QrCodeElement.rb +77 -0
- data/lib/ruby_client/Elements/QrCodeFnc1.rb +22 -0
- data/lib/ruby_client/Elements/RectangleElement.rb +109 -0
- data/lib/ruby_client/Elements/StackedGs1DataBarBarcodeElement.rb +90 -0
- data/lib/ruby_client/Elements/StackedGs1DataBarType.rb +23 -0
- data/lib/ruby_client/Elements/TextBarcodeElement.rb +48 -0
- data/lib/ruby_client/Elements/TextElement.rb +83 -0
- data/lib/ruby_client/Elements/ValueType.rb +16 -0
- data/lib/ruby_client/EncryptDocumentComponents.rb +16 -0
- data/lib/ruby_client/EndPointException.rb +7 -0
- data/lib/ruby_client/Endpoint.rb +38 -0
- data/lib/ruby_client/EndpointResource.rb +7 -0
- data/lib/ruby_client/ExcelInput.rb +49 -0
- data/lib/ruby_client/ExcelResource.rb +79 -0
- data/lib/ruby_client/Font.rb +276 -0
- data/lib/ruby_client/FontInformation.rb +9 -0
- data/lib/ruby_client/FontResource.rb +35 -0
- data/lib/ruby_client/FormField.rb +62 -0
- data/lib/ruby_client/FormFieldInformation.rb +45 -0
- data/lib/ruby_client/GoToAction.rb +53 -0
- data/lib/ruby_client/Grayscale.rb +41 -0
- data/lib/ruby_client/HtmlInput.rb +60 -0
- data/lib/ruby_client/HtmlResource.rb +34 -0
- data/lib/ruby_client/ImageInfo.rb +69 -0
- data/lib/ruby_client/ImageInformation.rb +57 -0
- data/lib/ruby_client/ImageInput.rb +150 -0
- data/lib/ruby_client/ImageResource.rb +89 -0
- data/lib/ruby_client/ImageResponse.rb +24 -0
- data/lib/ruby_client/Input.rb +53 -0
- data/lib/ruby_client/InputType.rb +41 -0
- data/lib/ruby_client/JsonResponse.rb +18 -0
- data/lib/ruby_client/LayoutDataResource.rb +48 -0
- data/lib/ruby_client/LineStyle.rb +79 -0
- data/lib/ruby_client/MergeOptions.rb +135 -0
- data/lib/ruby_client/MultiSelectListBoxInformation.rb +45 -0
- data/lib/ruby_client/Outline.rb +113 -0
- data/lib/ruby_client/OutlineList.rb +57 -0
- data/lib/ruby_client/OutlineStyle.rb +28 -0
- data/lib/ruby_client/OutputSize.rb +10 -0
- data/lib/ruby_client/PageInformation.rb +27 -0
- data/lib/ruby_client/PageInput.rb +152 -0
- data/lib/ruby_client/PageOrientation.rb +17 -0
- data/lib/ruby_client/PageSize.rb +127 -0
- data/lib/ruby_client/PageZoom.rb +33 -0
- data/lib/ruby_client/Pdf.rb +417 -0
- data/lib/ruby_client/PdfContent.rb +21 -0
- data/lib/ruby_client/PdfInfo.rb +68 -0
- data/lib/ruby_client/PdfInfoResponse.rb +27 -0
- data/lib/ruby_client/PdfInformation.rb +81 -0
- data/lib/ruby_client/PdfInput.rb +66 -0
- data/lib/ruby_client/PdfInstructions.rb +97 -0
- data/lib/ruby_client/PdfResource.rb +36 -0
- data/lib/ruby_client/PdfResponse.rb +23 -0
- data/lib/ruby_client/PdfText.rb +85 -0
- data/lib/ruby_client/PdfTextResponse.rb +27 -0
- data/lib/ruby_client/PdfXmp.rb +67 -0
- data/lib/ruby_client/PushButtonInformation.rb +21 -0
- data/lib/ruby_client/RC4128Security.rb +62 -0
- data/lib/ruby_client/Resource.rb +51 -0
- data/lib/ruby_client/ResourceType.rb +48 -0
- data/lib/ruby_client/Response.rb +39 -0
- data/lib/ruby_client/RgbColor.rb +1048 -0
- data/lib/ruby_client/Security.rb +73 -0
- data/lib/ruby_client/SecurityType.rb +23 -0
- data/lib/ruby_client/SignatureFieldInformation.rb +21 -0
- data/lib/ruby_client/Template.rb +46 -0
- data/lib/ruby_client/TextFieldInformation.rb +27 -0
- data/lib/ruby_client/TextReplace.rb +43 -0
- data/lib/ruby_client/UnitConverter.rb +111 -0
- data/lib/ruby_client/UrlAction.rb +31 -0
- data/lib/ruby_client/VAlign.rb +21 -0
- data/lib/ruby_client/WebColor.rb +18 -0
- data/lib/ruby_client/WordInput.rb +65 -0
- data/lib/ruby_client/WordResource.rb +82 -0
- data/lib/ruby_client/XmlResponse.rb +23 -0
- data/lib/ruby_client/version.rb +5 -0
- data/lib/ruby_client.rb +123 -0
- metadata +169 -0
@@ -0,0 +1,41 @@
|
|
1
|
+
module DynamicPDFApi
|
2
|
+
#
|
3
|
+
# Specifies an input type.
|
4
|
+
#
|
5
|
+
class InputType
|
6
|
+
#
|
7
|
+
# Pdf input.
|
8
|
+
#
|
9
|
+
PDF = "Pdf".freeze
|
10
|
+
|
11
|
+
#
|
12
|
+
# Image input.
|
13
|
+
#
|
14
|
+
IMAGE = "Image".freeze
|
15
|
+
|
16
|
+
#
|
17
|
+
# Dlex input.
|
18
|
+
#
|
19
|
+
DLEX = "Dlex".freeze
|
20
|
+
|
21
|
+
#
|
22
|
+
# Page input.
|
23
|
+
#
|
24
|
+
PAGE = "Page".freeze
|
25
|
+
|
26
|
+
#
|
27
|
+
# Html input.
|
28
|
+
#
|
29
|
+
HTML = "Html".freeze
|
30
|
+
|
31
|
+
#
|
32
|
+
# Word input.
|
33
|
+
#
|
34
|
+
WORD = "Word".freeze
|
35
|
+
|
36
|
+
#
|
37
|
+
# Excel input.
|
38
|
+
#
|
39
|
+
EXCEL = "Excel".freeze
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module DynamicPDFApi
|
2
|
+
require_relative 'Response'
|
3
|
+
|
4
|
+
#
|
5
|
+
# Represents the base class for json response.
|
6
|
+
#
|
7
|
+
class JsonResponse < Response
|
8
|
+
def initialize(json_content = nil)
|
9
|
+
super()
|
10
|
+
@json_content = json_content
|
11
|
+
end
|
12
|
+
|
13
|
+
#
|
14
|
+
# Gets the json content.
|
15
|
+
#
|
16
|
+
attr_accessor :json_content
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module DynamicPDFApi
|
2
|
+
require_relative 'Resource'
|
3
|
+
require_relative 'ResourceType'
|
4
|
+
|
5
|
+
#
|
6
|
+
#
|
7
|
+
# Represents the Layout data resource used to create the PDF reports.
|
8
|
+
#
|
9
|
+
class LayoutDataResource < Resource
|
10
|
+
#
|
11
|
+
# Initializes a new instance of the LayoutDataResource class using the layout data object and a resource
|
12
|
+
# name.
|
13
|
+
#
|
14
|
+
# @param layout [Object]|[String] Serializable object data to create PDF report or the layout data JSON file path.
|
15
|
+
# @param layout_data_resource_name [String] The name for layout data resource.
|
16
|
+
#
|
17
|
+
def initialize(layout = nil, layout_data_resource_name = nil)
|
18
|
+
super()
|
19
|
+
@data = if layout.is_a?(String)
|
20
|
+
Resource._get_file_data(layout)
|
21
|
+
else
|
22
|
+
layout.to_json
|
23
|
+
end
|
24
|
+
@layout_data_resource_name = if layout_data_resource_name.nil?
|
25
|
+
"#{SecureRandom.uuid}.json"
|
26
|
+
else
|
27
|
+
layout_data_resource_name
|
28
|
+
end
|
29
|
+
|
30
|
+
@_mime_type = 'application/json'
|
31
|
+
@_type = ResourceType::LAYOUT_DATA
|
32
|
+
@resource_name = @layout_data_resource_name
|
33
|
+
end
|
34
|
+
|
35
|
+
def _file_extension
|
36
|
+
'.json'
|
37
|
+
end
|
38
|
+
|
39
|
+
#
|
40
|
+
# Gets or sets name of the layout data resource.
|
41
|
+
#
|
42
|
+
attr_accessor :layout_data_resource_name
|
43
|
+
|
44
|
+
def to_json(_options = {})
|
45
|
+
JSON.pretty_generate({})
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
module DynamicPDFApi
|
2
|
+
#
|
3
|
+
# Represents a style of line.
|
4
|
+
#
|
5
|
+
class LineStyle
|
6
|
+
#
|
7
|
+
# Initializes a new instance of the LineStyle class.
|
8
|
+
#
|
9
|
+
# @param line [Array] The array specifying the line style.
|
10
|
+
# @param dash_phase [float] The phase of the line style.
|
11
|
+
#
|
12
|
+
def initialize(line, dash_phase = 0)
|
13
|
+
if line.is_a?(Array)
|
14
|
+
str_line_style = '['
|
15
|
+
(0..(line.length - 1)).each do |i|
|
16
|
+
val = line[i]
|
17
|
+
str_line_style = if i == (line.length - 1)
|
18
|
+
str_line_style + format('%.2f', val)
|
19
|
+
else
|
20
|
+
"#{str_line_style}#{format('%.2f', val)},"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
str_line_style += ']'
|
24
|
+
str_line_style += format('%.2f', dash_phase) if dash_phase != 0
|
25
|
+
@_line_style_string = str_line_style
|
26
|
+
else
|
27
|
+
@_line_style_string = line
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
attr_accessor :_line_style_string
|
32
|
+
|
33
|
+
#
|
34
|
+
# Gets a solid line.
|
35
|
+
#
|
36
|
+
def self.solid
|
37
|
+
LineStyle.new('solid')
|
38
|
+
end
|
39
|
+
|
40
|
+
#
|
41
|
+
# Gets a dotted line.
|
42
|
+
#
|
43
|
+
def self.dots
|
44
|
+
LineStyle.new('dots')
|
45
|
+
end
|
46
|
+
|
47
|
+
#
|
48
|
+
# Gets a line with small dashes.
|
49
|
+
#
|
50
|
+
def self.dash_small
|
51
|
+
LineStyle.new('dashSmall')
|
52
|
+
end
|
53
|
+
|
54
|
+
#
|
55
|
+
# Gets a dashed line.
|
56
|
+
#
|
57
|
+
def self.dash
|
58
|
+
LineStyle.new('dash')
|
59
|
+
end
|
60
|
+
|
61
|
+
#
|
62
|
+
# Gets a line with large dashes.
|
63
|
+
#
|
64
|
+
def self.dash_large
|
65
|
+
LineStyle.new('dashLarge')
|
66
|
+
end
|
67
|
+
|
68
|
+
#
|
69
|
+
# Gets a invisible line.
|
70
|
+
#
|
71
|
+
def self.none
|
72
|
+
LineStyle.new('none')
|
73
|
+
end
|
74
|
+
|
75
|
+
def to_json(_options = {})
|
76
|
+
JSON.pretty_generate({})
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,135 @@
|
|
1
|
+
module DynamicPDFApi
|
2
|
+
#
|
3
|
+
# Represents different options for merging PDF documents.
|
4
|
+
#
|
5
|
+
class MergeOptions
|
6
|
+
def initialize
|
7
|
+
@document_info = 'nil'
|
8
|
+
@document_java_script = 'nil'
|
9
|
+
@document_properties = 'nil'
|
10
|
+
@embedded_files = 'nil'
|
11
|
+
@form_fields = 'nil'
|
12
|
+
@forms_xfa_data = 'nil'
|
13
|
+
@logical_structure = 'nil'
|
14
|
+
@open_action = 'nil'
|
15
|
+
@optional_content_info = 'nil'
|
16
|
+
@out_lines = 'nil'
|
17
|
+
@output_intent = 'nil'
|
18
|
+
@page_annotations = 'nil'
|
19
|
+
@page_labels_and_sections = 'nil'
|
20
|
+
@root_form_field = 'nil'
|
21
|
+
@xmp_metadata = 'nil'
|
22
|
+
end
|
23
|
+
|
24
|
+
#
|
25
|
+
# Gets or sets a boolean indicating whether to import document information when merging.
|
26
|
+
#
|
27
|
+
attr_accessor :document_info
|
28
|
+
|
29
|
+
#
|
30
|
+
# Gets or sets a boolean indicating whether to import document level JavaScript when merging.
|
31
|
+
#
|
32
|
+
attr_accessor :document_java_script
|
33
|
+
|
34
|
+
#
|
35
|
+
# Gets or sets a boolean indicating whether to import document properties when merging.
|
36
|
+
#
|
37
|
+
attr_accessor :document_properties
|
38
|
+
|
39
|
+
#
|
40
|
+
# Gets or sets a boolean indicating whether to import embedded files when merging.
|
41
|
+
#
|
42
|
+
attr_accessor :embedded_files
|
43
|
+
|
44
|
+
#
|
45
|
+
# Gets or sets a boolean indicating whether to import form fields when merging.
|
46
|
+
#
|
47
|
+
attr_accessor :form_fields
|
48
|
+
|
49
|
+
#
|
50
|
+
# Gets or sets a boolean indicating whether to import XFA form data when merging.
|
51
|
+
#
|
52
|
+
attr_accessor :forms_xfa_data
|
53
|
+
|
54
|
+
#
|
55
|
+
# Gets or sets a boolean indicating whether to import logical structure (tagging information) when merging.
|
56
|
+
#
|
57
|
+
attr_accessor :logical_structure
|
58
|
+
|
59
|
+
#
|
60
|
+
# Gets or sets a boolean indicating whether to import document's opening action (initial page and zoom settings) when merging.
|
61
|
+
#
|
62
|
+
attr_accessor :open_action
|
63
|
+
|
64
|
+
#
|
65
|
+
# Gets or sets a boolean indicating whether to import optional content when merging.
|
66
|
+
#
|
67
|
+
attr_accessor :optional_content_info
|
68
|
+
|
69
|
+
#
|
70
|
+
# Gets or sets a boolean indicating whether to import outlines and bookmarks when merging.
|
71
|
+
#
|
72
|
+
attr_accessor :out_lines
|
73
|
+
|
74
|
+
#
|
75
|
+
# Gets or sets a boolean indicating whether to import OutputIntent when merging.
|
76
|
+
#
|
77
|
+
attr_accessor :output_intent
|
78
|
+
|
79
|
+
#
|
80
|
+
# Gets or sets a boolean indicating whether to import PageAnnotations when merging.
|
81
|
+
#
|
82
|
+
attr_accessor :page_annotations
|
83
|
+
|
84
|
+
#
|
85
|
+
# Gets or sets a boolean indicating whether to import PageLabelsAndSections when merging.
|
86
|
+
#
|
87
|
+
attr_accessor :page_labels_and_sections
|
88
|
+
|
89
|
+
#
|
90
|
+
# Gets or sets the root form field for imported form fields. Useful when merging a PDF repeatedly to have a better contorl on the form field names.
|
91
|
+
#
|
92
|
+
attr_accessor :root_form_field
|
93
|
+
|
94
|
+
#
|
95
|
+
# Gets or sets a boolean indicating whether to import XmpMetadata when merging.
|
96
|
+
#
|
97
|
+
attr_accessor :xmp_metadata
|
98
|
+
|
99
|
+
def to_json(_options = {})
|
100
|
+
json_array = {}
|
101
|
+
|
102
|
+
json_array['documentInfo'] = @document_info if @document_info != 'nil'
|
103
|
+
|
104
|
+
json_array['documentJavaScript'] = @document_java_script if @document_java_script != 'nil'
|
105
|
+
|
106
|
+
json_array['documentProperties'] = @document_properties if @document_properties != 'nil'
|
107
|
+
|
108
|
+
json_array['embeddedFiles'] = @embedded_files if @embedded_files != 'nil'
|
109
|
+
|
110
|
+
json_array['formFields'] = @form_fields if @form_fields != 'nil'
|
111
|
+
|
112
|
+
json_array['formsXfaData'] = @forms_xfa_data if @forms_xfa_data != 'nil'
|
113
|
+
|
114
|
+
json_array['logicalStructure'] = @logical_structure if @logical_structure != 'nil'
|
115
|
+
|
116
|
+
json_array['openAction'] = @open_action if @open_action != 'nil'
|
117
|
+
|
118
|
+
json_array['optionalContentInfo'] = @optional_content_info if @optional_content_info != 'nil'
|
119
|
+
|
120
|
+
json_array['outlines'] = @out_lines if @out_lines != 'nil'
|
121
|
+
|
122
|
+
json_array['outputIntent'] = @output_intent if @output_intent != 'nil'
|
123
|
+
|
124
|
+
json_array['pageAnnotations'] = @page_annotations if @page_annotations != 'nil'
|
125
|
+
|
126
|
+
json_array['pageLabelsAndSections'] = @page_labels_and_sections if @page_labels_and_sections != 'nil'
|
127
|
+
|
128
|
+
json_array['rootFormField'] = @root_form_field if @root_form_field != 'nil'
|
129
|
+
|
130
|
+
json_array['xmpMetadata'] = @xmp_metadata if @xmp_metadata != 'nil'
|
131
|
+
|
132
|
+
JSON.pretty_generate(json_array)
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module DynamicPDFApi
|
2
|
+
#
|
3
|
+
# Represents information of a MultiSelectListBox.
|
4
|
+
#
|
5
|
+
class MultiSelectListBoxInformation
|
6
|
+
def initialize
|
7
|
+
@name = nil
|
8
|
+
@values = {}
|
9
|
+
@default_values = {}
|
10
|
+
@export_values = {}
|
11
|
+
@items = {}
|
12
|
+
@items_export_values = {}
|
13
|
+
end
|
14
|
+
|
15
|
+
#
|
16
|
+
# Gets or Sets the name of a MultiSelectListBox.
|
17
|
+
#
|
18
|
+
attr_accessor :name
|
19
|
+
|
20
|
+
#
|
21
|
+
# Gets or sets a collection of values of the MultiSelectListBox.
|
22
|
+
#
|
23
|
+
attr_accessor :values
|
24
|
+
|
25
|
+
#
|
26
|
+
# Gets or sets a collection of default values of the MultiSelectListBox.
|
27
|
+
#
|
28
|
+
attr_accessor :default_values
|
29
|
+
|
30
|
+
#
|
31
|
+
# Gets or sets a collection of export values of the MultiSelectListBox.
|
32
|
+
#
|
33
|
+
attr_accessor :export_values
|
34
|
+
|
35
|
+
#
|
36
|
+
# Gets or sets a collection of items of the MultiSelectListBox.
|
37
|
+
#
|
38
|
+
attr_accessor :items
|
39
|
+
|
40
|
+
#
|
41
|
+
# Gets or sets a collection of export values of the MultiSelectListBox.
|
42
|
+
#
|
43
|
+
attr_accessor :items_export_values
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,113 @@
|
|
1
|
+
module DynamicPDFApi
|
2
|
+
require_relative "Action"
|
3
|
+
require_relative "OutlineStyle"
|
4
|
+
# require_relative 'OutlineList'
|
5
|
+
|
6
|
+
autoload :OutlineList, File.join(File.dirname(__FILE__), *%w[OutlineList.rb])
|
7
|
+
|
8
|
+
#
|
9
|
+
# Represents an outline.
|
10
|
+
#
|
11
|
+
class Outline
|
12
|
+
#
|
13
|
+
# Initializes a new instance of the Outline class.
|
14
|
+
#
|
15
|
+
# @param input [PdfInput] The input of type PdfInput .
|
16
|
+
# @param action [Action] Action of the outline.
|
17
|
+
#
|
18
|
+
def initialize(input, action = nil)
|
19
|
+
@_color_name = nil
|
20
|
+
@text = nil
|
21
|
+
@style = nil
|
22
|
+
@expanded = nil
|
23
|
+
@children = nil
|
24
|
+
@action = nil
|
25
|
+
@_from_input_id = nil
|
26
|
+
@color = nil
|
27
|
+
|
28
|
+
@children = OutlineList.new
|
29
|
+
if input.is_a?(String)
|
30
|
+
@text = input
|
31
|
+
@action = action
|
32
|
+
else
|
33
|
+
@_from_input_id = input.id
|
34
|
+
input.merge_options = MergeOptions.new if input.merge_options.nil?
|
35
|
+
input.merge_options.out_lines = false
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
attr_accessor :_color_name, :_from_input_id
|
40
|
+
|
41
|
+
#
|
42
|
+
# Gets or sets the text of the outline.
|
43
|
+
#
|
44
|
+
attr_accessor :text
|
45
|
+
|
46
|
+
#
|
47
|
+
# Gets or sets the style of the outline.
|
48
|
+
#
|
49
|
+
attr_accessor :style
|
50
|
+
|
51
|
+
#
|
52
|
+
# Gets or sets a value specifying if the outline is expanded.
|
53
|
+
#
|
54
|
+
attr_accessor :expanded
|
55
|
+
|
56
|
+
#
|
57
|
+
# Gets or sets a collection of child outlines.
|
58
|
+
#
|
59
|
+
attr_accessor :children
|
60
|
+
#
|
61
|
+
# Gets or sets the Action of the outline.
|
62
|
+
#
|
63
|
+
attr_accessor :action
|
64
|
+
|
65
|
+
#
|
66
|
+
# Gets or sets the color of the outline.
|
67
|
+
#
|
68
|
+
attr_accessor :color
|
69
|
+
|
70
|
+
#
|
71
|
+
# Gets collection of child outlines.
|
72
|
+
#
|
73
|
+
# @return OutlineList Collection of child outlines.
|
74
|
+
#
|
75
|
+
def _get_children
|
76
|
+
if (@children != nil)
|
77
|
+
@children&._out_lines
|
78
|
+
else
|
79
|
+
nil
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def to_json(_options = {})
|
84
|
+
json_array = {}
|
85
|
+
|
86
|
+
json_array["type"] = "Outline"
|
87
|
+
|
88
|
+
unless @color.nil?
|
89
|
+
color_string = @color._color_string
|
90
|
+
json_array['color'] = color_string unless color_string.nil?
|
91
|
+
end
|
92
|
+
|
93
|
+
json_array["text"] = @text unless @text.nil?
|
94
|
+
|
95
|
+
json_array["linkTo"] = @action unless @action.nil?
|
96
|
+
|
97
|
+
json_array["style"] = @style unless @style.nil?
|
98
|
+
|
99
|
+
json_array["expanded"] = @expanded unless @expanded.nil?
|
100
|
+
|
101
|
+
if !@children.nil? && !@children._out_lines.empty?
|
102
|
+
children_array = []
|
103
|
+
(0..(@children._out_lines.length - 1)).each do |i|
|
104
|
+
children_array << @children._out_lines[i] unless @children._out_lines[i].nil?
|
105
|
+
end
|
106
|
+
json_array["children"] = children_array
|
107
|
+
end
|
108
|
+
json_array["fromInputID"] = @_from_input_id unless @_from_input_id.nil?
|
109
|
+
|
110
|
+
JSON.pretty_generate(json_array)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
module DynamicPDFApi
|
2
|
+
require_relative 'PageZoom'
|
3
|
+
require_relative 'GoToAction'
|
4
|
+
require_relative 'Outline'
|
5
|
+
require_relative 'PdfInput'
|
6
|
+
|
7
|
+
class OutlineList
|
8
|
+
def initialize
|
9
|
+
@_out_lines = []
|
10
|
+
end
|
11
|
+
|
12
|
+
#
|
13
|
+
# Adds an Outline object to the outline list.
|
14
|
+
#
|
15
|
+
# @param text [String] Text of the outline.
|
16
|
+
# @param input [String]|Input URL the action launches or any of the ImageInput, DlexInput, PdfInput or PageInput objects to create PDF or nil.
|
17
|
+
# @param page_offset [int] Page number to navigate.
|
18
|
+
# @param page_zoom [PageZoom] PageZoom to display the destination.
|
19
|
+
#
|
20
|
+
# @return Outline The Outline object that is created.
|
21
|
+
#
|
22
|
+
def add(text, input = nil, page_offset = 0, page_zoom = PageZoom::FIT_PAGE)
|
23
|
+
if input.nil?
|
24
|
+
out_line = Outline.new(text)
|
25
|
+
@_out_lines << out_line
|
26
|
+
out_line
|
27
|
+
elsif input.is_a?(String)
|
28
|
+
out_line = Outline.new(text, UrlAction.new(input))
|
29
|
+
@_out_lines << out_line
|
30
|
+
out_line
|
31
|
+
elsif input.is_a?(Object)
|
32
|
+
link_to = GoToAction.new(input)
|
33
|
+
link_to.page_offset = page_offset
|
34
|
+
link_to.page_zoom = page_zoom
|
35
|
+
out_line = Outline.new(text, link_to)
|
36
|
+
@_out_lines << out_line
|
37
|
+
out_line
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def add_pdf_outlines(pdf_input)
|
42
|
+
@_out_lines << Outline.new(pdf_input)
|
43
|
+
end
|
44
|
+
|
45
|
+
attr_accessor :_out_lines
|
46
|
+
|
47
|
+
def to_json(_options = {})
|
48
|
+
json_array = []
|
49
|
+
|
50
|
+
(0..(@_out_lines.length - 1)).each do |i|
|
51
|
+
json_array << @_out_lines[i] unless @_out_lines[i].nil?
|
52
|
+
end
|
53
|
+
|
54
|
+
JSON.pretty_generate(json_array)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module DynamicPDFApi
|
2
|
+
#
|
3
|
+
#
|
4
|
+
# Specifies the style of the outline.
|
5
|
+
#
|
6
|
+
#
|
7
|
+
class OutlineStyle
|
8
|
+
#
|
9
|
+
# Bold.
|
10
|
+
#
|
11
|
+
BOLD = 'bold'.freeze
|
12
|
+
|
13
|
+
#
|
14
|
+
# Bold Italic.
|
15
|
+
#
|
16
|
+
BOLD_ITALIC = 'boldItalic'.freeze
|
17
|
+
|
18
|
+
#
|
19
|
+
# Italic.
|
20
|
+
#
|
21
|
+
ITALIC = 'italic'.freeze
|
22
|
+
|
23
|
+
#
|
24
|
+
# Regular.
|
25
|
+
#
|
26
|
+
REGULAR = 'regular'.freeze
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module DynamicPDFApi
|
2
|
+
#
|
3
|
+
# Represents a page information.
|
4
|
+
#
|
5
|
+
class PageInformation
|
6
|
+
def initialize
|
7
|
+
@page_number = nil
|
8
|
+
@width = nil
|
9
|
+
@height = nil
|
10
|
+
end
|
11
|
+
|
12
|
+
#
|
13
|
+
# Gets or sets the page number.
|
14
|
+
#
|
15
|
+
attr_accessor :page_number
|
16
|
+
|
17
|
+
#
|
18
|
+
# Gets or sets the width of the page.
|
19
|
+
#
|
20
|
+
attr_accessor :width
|
21
|
+
|
22
|
+
#
|
23
|
+
# Gets or sets the height of the page.
|
24
|
+
#
|
25
|
+
attr_accessor :height
|
26
|
+
end
|
27
|
+
end
|