dynamicpdf_api 1.0.0.pre.beta2 → 1.1.0
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 +4 -4
- data/lib/ruby_client/Imaging/BmpColorFormat.rb +20 -0
- data/lib/ruby_client/Imaging/BmpImageFormat.rb +32 -0
- data/lib/ruby_client/Imaging/BmpMonochromeColorFormat.rb +37 -0
- data/lib/ruby_client/Imaging/ColorFormat.rb +18 -0
- data/lib/ruby_client/Imaging/ColorFormatType.rb +31 -0
- data/lib/ruby_client/Imaging/CompressionType.rb +16 -0
- data/lib/ruby_client/Imaging/DitheringAlgorithm.rb +21 -0
- data/lib/ruby_client/Imaging/DpiImageSize.rb +36 -0
- data/lib/ruby_client/Imaging/FixedImageSize.rb +39 -0
- data/lib/ruby_client/Imaging/GifImageFormat.rb +33 -0
- data/lib/ruby_client/Imaging/ImageFormat.rb +31 -0
- data/lib/ruby_client/Imaging/ImageFormatType.rb +31 -0
- data/lib/ruby_client/Imaging/ImageSize.rb +26 -0
- data/lib/ruby_client/Imaging/ImageSizeType.rb +26 -0
- data/lib/ruby_client/Imaging/ImageSizeUnit.rb +21 -0
- data/lib/ruby_client/Imaging/JpegImageFormat.rb +31 -0
- data/lib/ruby_client/Imaging/MaxImageSize.rb +38 -0
- data/lib/ruby_client/Imaging/PdfImage.rb +210 -0
- data/lib/ruby_client/Imaging/PdfImageResponse.rb +40 -0
- data/lib/ruby_client/Imaging/PercentageImageSize.rb +35 -0
- data/lib/ruby_client/Imaging/PngColorFormat.rb +18 -0
- data/lib/ruby_client/Imaging/PngImageFormat.rb +33 -0
- data/lib/ruby_client/Imaging/PngIndexedColorFormat.rb +32 -0
- data/lib/ruby_client/Imaging/PngMonochromeColorFormat.rb +23 -0
- data/lib/ruby_client/Imaging/QuantizationAlgorithm.rb +26 -0
- data/lib/ruby_client/Imaging/TiffColorFormat.rb +17 -0
- data/lib/ruby_client/Imaging/TiffImageFormat.rb +34 -0
- data/lib/ruby_client/Imaging/TiffIndexedColorFormat.rb +37 -0
- data/lib/ruby_client/Imaging/TiffMonochromeColorFormat.rb +40 -0
- data/lib/ruby_client/Outline.rb +0 -2
- data/lib/ruby_client/PageInput.rb +51 -45
- data/lib/ruby_client/Pdf.rb +22 -3
- data/lib/ruby_client/PdfInstructions.rb +3 -3
- data/lib/ruby_client/version.rb +1 -1
- data/lib/ruby_client.rb +29 -0
- metadata +33 -4
@@ -0,0 +1,210 @@
|
|
1
|
+
module DynamicPDFApi
|
2
|
+
|
3
|
+
require "net/http"
|
4
|
+
require "net/https"
|
5
|
+
require "uri"
|
6
|
+
require "json"
|
7
|
+
require "openssl"
|
8
|
+
|
9
|
+
require_relative '..\Endpoint'
|
10
|
+
require_relative '..\PdfResource'
|
11
|
+
require_relative '..\EndPointException'
|
12
|
+
require_relative "PdfImageResponse"
|
13
|
+
require_relative "ImageFormat"
|
14
|
+
require_relative "ImageSize"
|
15
|
+
|
16
|
+
# Represents a PDF Rasterizing endpoint that converts PDF to image.
|
17
|
+
class PdfImage < Endpoint
|
18
|
+
|
19
|
+
#
|
20
|
+
# Represents a PdfResource for converting PDF pages to images.
|
21
|
+
#
|
22
|
+
attr_reader :resource
|
23
|
+
|
24
|
+
#
|
25
|
+
# Gets or sets the starting page number for rasterization.
|
26
|
+
#
|
27
|
+
attr_accessor :start_page_number
|
28
|
+
|
29
|
+
#
|
30
|
+
# Gets or sets the number of pages to rasterize.
|
31
|
+
#
|
32
|
+
attr_accessor :page_count
|
33
|
+
|
34
|
+
#
|
35
|
+
# Gets or sets the image format for rasterization.
|
36
|
+
#
|
37
|
+
attr_accessor :image_format
|
38
|
+
|
39
|
+
#
|
40
|
+
# Gets or sets the size of the rasterized images.
|
41
|
+
#
|
42
|
+
attr_accessor :image_size
|
43
|
+
|
44
|
+
def initialize(resource)
|
45
|
+
@resource = resource
|
46
|
+
@_endpoint_name = 'pdf-image'
|
47
|
+
end
|
48
|
+
|
49
|
+
def process
|
50
|
+
header = {
|
51
|
+
'authorization': "Bearer #{@api_key}",
|
52
|
+
'Expect': "100-continue",
|
53
|
+
}
|
54
|
+
uri = URI.parse("#{@base_url}/v1.0/#{@_endpoint_name}")
|
55
|
+
params = {}
|
56
|
+
if @start_page_number!=nil
|
57
|
+
params['sp'] = @start_page_number
|
58
|
+
params['pc'] = @page_count
|
59
|
+
end
|
60
|
+
|
61
|
+
# Adding ImageSize parameters if @image_size is present
|
62
|
+
if @image_size
|
63
|
+
case @image_size
|
64
|
+
when DpiImageSize
|
65
|
+
params['is'] = @image_size.type.to_s
|
66
|
+
params['hd'] = @image_size.horizontal_dpi.to_s if @image_size.horizontal_dpi
|
67
|
+
params['vd'] = @image_size.vertical_dpi.to_s if @image_size.vertical_dpi
|
68
|
+
when FixedImageSize
|
69
|
+
params['is'] = @image_size.type.to_s
|
70
|
+
params['ht'] = @image_size.height.to_s if @image_size.height
|
71
|
+
params['wd'] = @image_size.width.to_s if @image_size.width
|
72
|
+
params['ut'] = @image_size.unit.to_s if @image_size.unit
|
73
|
+
when MaxImageSize
|
74
|
+
params['is'] = @image_size.type.to_s
|
75
|
+
params['mh'] = @image_size.max_height.to_s if @image_size.max_height
|
76
|
+
params['mw'] = @image_size.max_width.to_s if @image_size.max_width
|
77
|
+
params['ut'] = @image_size.unit.to_s if @image_size.unit
|
78
|
+
when PercentageImageSize
|
79
|
+
params['is'] = @image_size.type.to_s
|
80
|
+
params['hp'] = @image_size.horizontal_percentage.to_s if @image_size.horizontal_percentage
|
81
|
+
params['vp'] = @image_size.vertical_percentage.to_s if @image_size.vertical_percentage
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
# Adding ImageFormat parameters if @image_format is present
|
86
|
+
if @image_format
|
87
|
+
case @image_format
|
88
|
+
when GifImageFormat
|
89
|
+
params['if'] = @image_format.type.to_s
|
90
|
+
params['dp'] = @image_format.dithering_percent.to_s if @image_format.dithering_percent
|
91
|
+
params['da'] = @image_format.dithering_algorithm.to_s if @image_format.dithering_algorithm
|
92
|
+
when JpegImageFormat
|
93
|
+
params['if'] = @image_format.type.to_s
|
94
|
+
params['qt'] = @image_format.quality.to_s if @image_format.quality
|
95
|
+
when PngImageFormat
|
96
|
+
params['if'] = @image_format.type.to_s
|
97
|
+
if @image_format.color_format
|
98
|
+
params['cf'] = @image_format.color_format.type.to_s
|
99
|
+
case @image_format.color_format
|
100
|
+
when PngIndexedColorFormat
|
101
|
+
params['da'] = @image_format.color_format.dithering_algorithm.to_s if @image_format.color_format.dithering_algorithm
|
102
|
+
params['dp'] = @image_format.color_format.dithering_percent.to_s if @image_format.color_format.dithering_percent
|
103
|
+
params['qa'] = @image_format.color_format.quantization_algorithm.to_s if @image_format.color_format.quantization_algorithm
|
104
|
+
when PngMonochromeColorFormat
|
105
|
+
params['bt'] = @image_format.color_format.black_threshold.to_s if @image_format.color_format.black_threshold
|
106
|
+
params['da'] = @image_format.color_format.dithering_algorithm.to_s if @image_format.color_format.dithering_algorithm
|
107
|
+
params['dp'] = @image_format.color_format.dithering_percent.to_s if @image_format.color_format.dithering_percent
|
108
|
+
end
|
109
|
+
end
|
110
|
+
when TiffImageFormat
|
111
|
+
params['if'] = @image_format.type.to_s
|
112
|
+
params['mp'] = 'true' if @image_format.multi_page
|
113
|
+
if @image_format.color_format
|
114
|
+
params['cf'] = @image_format.color_format.type.to_s
|
115
|
+
case @image_format.color_format
|
116
|
+
when TiffIndexedColorFormat
|
117
|
+
params['da'] = @image_format.color_format.dithering_algorithm.to_s if @image_format.color_format.dithering_algorithm
|
118
|
+
params['dp'] = @image_format.color_format.dithering_percent.to_s if @image_format.color_format.dithering_percent
|
119
|
+
params['qa'] = @image_format.color_format.quantization_algorithm.to_s if @image_format.color_format.quantization_algorithm
|
120
|
+
when TiffMonochromeColorFormat
|
121
|
+
params['ct'] = @image_format.color_format.compression_type.to_s if @image_format.color_format.compression_type
|
122
|
+
params['bt'] = @image_format.color_format.black_threshold.to_s if @image_format.color_format.black_threshold
|
123
|
+
params['da'] = @image_format.color_format.dithering_algorithm.to_s if @image_format.color_format.dithering_algorithm
|
124
|
+
params['dp'] = @image_format.color_format.dithering_percent.to_s if @image_format.color_format.dithering_percent
|
125
|
+
end
|
126
|
+
end
|
127
|
+
when BmpImageFormat
|
128
|
+
params['if'] = @image_format.type.to_s
|
129
|
+
if @image_format.color_format
|
130
|
+
params['cf'] = @image_format.color_format.type.to_s
|
131
|
+
case @image_format.color_format
|
132
|
+
when BmpMonochromeColorFormat
|
133
|
+
params['bt'] = @image_format.color_format.black_threshold.to_s if @image_format.color_format.black_threshold
|
134
|
+
params['dp'] = @image_format.color_format.dithering_percent.to_s if @image_format.color_format.dithering_percent
|
135
|
+
params['da'] = @image_format.color_format.dithering_algorithm.to_s if @image_format.color_format.dithering_algorithm
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
uri.query = URI.encode_www_form(params)
|
142
|
+
|
143
|
+
request = Net::HTTP::Post.new(uri.request_uri, header)
|
144
|
+
request.set_form_data(params)
|
145
|
+
req_options = {
|
146
|
+
use_ssl: uri.scheme == 'https',
|
147
|
+
verify_mode: OpenSSL::SSL::VERIFY_NONE
|
148
|
+
}
|
149
|
+
|
150
|
+
resource_array = []
|
151
|
+
resource_array << ['pdf', @resource.data, { content_type: @resource._mime_type, filename: @resource.resource_name }] if !@resource.nil?
|
152
|
+
|
153
|
+
request.set_form(resource_array, "multipart/form-data")
|
154
|
+
|
155
|
+
response = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|
|
156
|
+
http.request(request)
|
157
|
+
end
|
158
|
+
|
159
|
+
rasterizer_response = PdfImageResponse.new
|
160
|
+
if @resource == nil
|
161
|
+
raise 'Required a PDF Resource.'
|
162
|
+
end
|
163
|
+
rasterizer_response.status_code = response.code
|
164
|
+
out_data = response.body
|
165
|
+
if rasterizer_response.status_code == "200"
|
166
|
+
pdf_image = JSON.parse(out_data)
|
167
|
+
|
168
|
+
image_type = pdf_image['contentType']
|
169
|
+
rasterizer_response.image_format = image_type.split('/')[1]
|
170
|
+
rasterizer_response.content_type = image_type
|
171
|
+
rasterizer_response.horizontal_dpi = pdf_image['horizontalDpi']
|
172
|
+
rasterizer_response.vertical_dpi = pdf_image['verticalDpi']
|
173
|
+
|
174
|
+
pdf_image['images'].each do |img|
|
175
|
+
image = Image.new
|
176
|
+
image.page_number = img['pageNumber'] || 0
|
177
|
+
image.data = img['data'] || ''
|
178
|
+
image.billed_pages = img['billedPages'] || 0
|
179
|
+
image.width = img['width'] || 0
|
180
|
+
image.height = img['height'] || 0
|
181
|
+
rasterizer_response.images << image
|
182
|
+
end
|
183
|
+
|
184
|
+
rasterizer_response.status_code = response.code
|
185
|
+
rasterizer_response.is_successful = true
|
186
|
+
else
|
187
|
+
rasterizer_response.error_json = out_data
|
188
|
+
rasterizer_response.error_message = if !out_data_json["message"].nil?
|
189
|
+
out_data_json["message"]
|
190
|
+
else
|
191
|
+
"status_code : #{Net::HTTPResponse::CODE_TO_OBJ[rasterizer_response.status_code]}"
|
192
|
+
end
|
193
|
+
rasterizer_response.error_id = out_data_json["id"]
|
194
|
+
rasterizer_response.is_successful = false
|
195
|
+
end
|
196
|
+
|
197
|
+
rasterizer_response
|
198
|
+
end
|
199
|
+
|
200
|
+
def to_json(_options = {})
|
201
|
+
json_array = {}
|
202
|
+
|
203
|
+
json_array["startPageNumber"] = @start_page_number unless @start_page_number.nil?
|
204
|
+
json_array["pageCount"] = @page_count unless @page_count.nil?
|
205
|
+
json_array["imageFormat"] = @image_format unless @image_format.nil?
|
206
|
+
json_array["imageSize"] = @image_size unless @image_size.nil?
|
207
|
+
JSON.pretty_generate(json_array)
|
208
|
+
end
|
209
|
+
end
|
210
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module DynamicPDFApi
|
2
|
+
require_relative '..\Response'
|
3
|
+
|
4
|
+
#
|
5
|
+
# Represents a response from the rasterizer operation.
|
6
|
+
#
|
7
|
+
class PdfImageResponse < Response
|
8
|
+
|
9
|
+
attr_accessor :image_format
|
10
|
+
|
11
|
+
attr_accessor :images
|
12
|
+
|
13
|
+
attr_accessor :content_type
|
14
|
+
|
15
|
+
attr_accessor :horizontal_dpi
|
16
|
+
|
17
|
+
attr_accessor :vertical_dpi
|
18
|
+
|
19
|
+
#
|
20
|
+
# Initializes a new instance of the RasterizerResponse class.
|
21
|
+
#
|
22
|
+
def initialize
|
23
|
+
@image_format = nil
|
24
|
+
@images = []
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
class Image
|
29
|
+
attr_accessor :page_number
|
30
|
+
|
31
|
+
attr_accessor :data
|
32
|
+
|
33
|
+
attr_accessor :billed_pages
|
34
|
+
|
35
|
+
attr_accessor :width
|
36
|
+
|
37
|
+
attr_accessor :height
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module DynamicPDFApi
|
2
|
+
require_relative "ImageSize"
|
3
|
+
require_relative "ImageSizeType"
|
4
|
+
|
5
|
+
#
|
6
|
+
# Represents an image size based on percentage scaling.
|
7
|
+
#
|
8
|
+
class PercentageImageSize < ImageSize
|
9
|
+
attr_accessor :horizontal_percentage # Gets or sets the horizontal scaling percentage.
|
10
|
+
attr_accessor :vertical_percentage # Gets or sets the vertical scaling percentage.
|
11
|
+
|
12
|
+
#
|
13
|
+
# Initializes a new instance of the PercentageImageSize class.
|
14
|
+
#
|
15
|
+
def initialize
|
16
|
+
super()
|
17
|
+
@horizontal_percentage = nil
|
18
|
+
@vertical_percentage = nil
|
19
|
+
@type = ImageSizeType::Percentage
|
20
|
+
end
|
21
|
+
|
22
|
+
#
|
23
|
+
# Returns a JSON representation of the PercentageImageSize object.
|
24
|
+
#
|
25
|
+
# @return [String] JSON string representing the PercentageImageSize object.
|
26
|
+
#
|
27
|
+
def to_json(_options = {})
|
28
|
+
json_array = {}
|
29
|
+
json_array['type'] = 'percentage'
|
30
|
+
json_array['horizontalPercentage'] = @horizontal_percentage
|
31
|
+
json_array['verticalPercentage'] = @vertical_percentage
|
32
|
+
JSON.pretty_generate(json_array)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module DynamicPDFApi
|
2
|
+
require_relative 'ColorFormatType'
|
3
|
+
require_relative 'ColorFormat'
|
4
|
+
|
5
|
+
#
|
6
|
+
# Base class for PNG color formats, used for RGB, RGBA, and Grayscale color formats.
|
7
|
+
#
|
8
|
+
class PngColorFormat < ColorFormat
|
9
|
+
#
|
10
|
+
# Initializes a new instance of the PngColorFormat class.
|
11
|
+
#
|
12
|
+
# @param type [ColorFormatType] The color format type.
|
13
|
+
#
|
14
|
+
def initialize(type)
|
15
|
+
@type = type
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module DynamicPDFApi
|
2
|
+
|
3
|
+
require_relative 'ImageFormatType'
|
4
|
+
require_relative 'ImageFormat'
|
5
|
+
|
6
|
+
#
|
7
|
+
# Represents PNG image format with color format.
|
8
|
+
#
|
9
|
+
class PngImageFormat < ImageFormat
|
10
|
+
attr_accessor :color_format # Gets or sets the PngColorFormat for PNG.
|
11
|
+
|
12
|
+
#
|
13
|
+
# Initializes a new instance of the PngImageFormat class.
|
14
|
+
#
|
15
|
+
def initialize
|
16
|
+
super(ImageFormatType::PNG)
|
17
|
+
@color_format = nil
|
18
|
+
end
|
19
|
+
|
20
|
+
#
|
21
|
+
# Returns a JSON representation of the PngImageFormat object.
|
22
|
+
#
|
23
|
+
# @return [String] JSON string representing the PngImageFormat object.
|
24
|
+
#
|
25
|
+
def to_json(_options = {})
|
26
|
+
json_array = {}
|
27
|
+
json_array['type'] = 'png'
|
28
|
+
|
29
|
+
json_array['colorFormat'] = @color_format
|
30
|
+
JSON.pretty_generate(json_array)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module DynamicPDFApi
|
2
|
+
require_relative 'PngColorFormat'
|
3
|
+
require_relative 'ColorFormatType'
|
4
|
+
|
5
|
+
#
|
6
|
+
# Represents indexed color format for PNG.
|
7
|
+
#
|
8
|
+
class PngIndexedColorFormat < PngColorFormat
|
9
|
+
attr_accessor :quantization_algorithm # Gets or sets the QuantizationAlgorithm for PNG.
|
10
|
+
attr_accessor :dithering_percent # Gets or sets the dithering percentage for PNG.
|
11
|
+
attr_accessor :dithering_algorithm # Gets or sets the DitheringAlgorithm for PNG.
|
12
|
+
|
13
|
+
#
|
14
|
+
# Initializes a new instance of the PngIndexedColorFormat class with indexed color format type.
|
15
|
+
#
|
16
|
+
def initialize
|
17
|
+
super(ColorFormatType::Indexed)
|
18
|
+
@quantization_algorithm = nil
|
19
|
+
@dithering_percent = nil
|
20
|
+
@dithering_algorithm = nil
|
21
|
+
end
|
22
|
+
|
23
|
+
def to_json(_options = {})
|
24
|
+
json_array = {}
|
25
|
+
json_array['quantizationAlgorithm'] = @quantization_algorithm
|
26
|
+
json_array['ditheringPercent'] = @dithering_percent
|
27
|
+
json_array['ditheringAlgorithm'] = @dithering_algorithm
|
28
|
+
JSON.pretty_generate(json_array)
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module DynamicPDFApi
|
2
|
+
require_relative 'PngColorFormat'
|
3
|
+
require_relative 'ColorFormatType'
|
4
|
+
|
5
|
+
#
|
6
|
+
# Represents monochrome color format for PNG with black threshold.
|
7
|
+
#
|
8
|
+
class PngMonochromeColorFormat < PngColorFormat
|
9
|
+
attr_accessor :black_threshold # Gets or sets the black threshold for monochrome PNG, ranges from 0-255.
|
10
|
+
attr_accessor :dithering_percent # Gets or sets the dithering percentage for PNG.
|
11
|
+
attr_accessor :dithering_algorithm # Gets or sets the DitheringAlgorithm for PNG.
|
12
|
+
|
13
|
+
#
|
14
|
+
# Initializes a new instance of the PngMonochromeColorFormat class with monochrome color format type.
|
15
|
+
#
|
16
|
+
def initialize
|
17
|
+
super(ColorFormatType::Monochrome)
|
18
|
+
@black_threshold = nil
|
19
|
+
@dithering_percent = nil
|
20
|
+
@dithering_algorithm = nil
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module DynamicPDFApi
|
2
|
+
#
|
3
|
+
# Enum representing quantization algorithms.
|
4
|
+
#
|
5
|
+
class QuantizationAlgorithm
|
6
|
+
#
|
7
|
+
# Octree quantization algorithm.
|
8
|
+
#
|
9
|
+
Octree = :Octree.freeze
|
10
|
+
|
11
|
+
#
|
12
|
+
# Web-safe color quantization algorithm.
|
13
|
+
#
|
14
|
+
WebSafe = :WebSafe.freeze
|
15
|
+
|
16
|
+
#
|
17
|
+
# Werner quantization algorithm.
|
18
|
+
#
|
19
|
+
Werner = :Werner.freeze
|
20
|
+
|
21
|
+
#
|
22
|
+
# Wu quantization algorithm.
|
23
|
+
#
|
24
|
+
WU = :WU.freeze
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require_relative "ColorFormat"
|
2
|
+
|
3
|
+
module DynamicPDFApi
|
4
|
+
#
|
5
|
+
# Base class for TIFF color formats and used for RGB and Grayscale color formats.
|
6
|
+
#
|
7
|
+
class TiffColorFormat < ColorFormat
|
8
|
+
#
|
9
|
+
# Initializes a new instance of the TiffColorFormat class with the specified color format type.
|
10
|
+
#
|
11
|
+
# @param type [ColorFormatType] The color format type.
|
12
|
+
#
|
13
|
+
def initialize(type)
|
14
|
+
@type = type
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require_relative "ImageFormat"
|
2
|
+
require_relative "ImageFormatType"
|
3
|
+
|
4
|
+
module DynamicPDFApi
|
5
|
+
#
|
6
|
+
# Represents TIFF image format with color format.
|
7
|
+
#
|
8
|
+
class TiffImageFormat < ImageFormat
|
9
|
+
attr_accessor :multi_page # Gets or sets a value indicating whether the TIFF image format supports multiple pages.
|
10
|
+
attr_accessor :color_format # Gets or sets the color format for TIFF, TiffColorFormat.
|
11
|
+
|
12
|
+
#
|
13
|
+
# Initializes a new instance of the TiffImageFormat class.
|
14
|
+
#
|
15
|
+
def initialize
|
16
|
+
super(ImageFormatType::TIFF)
|
17
|
+
@multi_page = false
|
18
|
+
@color_format = nil
|
19
|
+
end
|
20
|
+
|
21
|
+
#
|
22
|
+
# Returns a JSON representation of the TiffImageFormat object.
|
23
|
+
#
|
24
|
+
# @return [String] JSON string representing the TiffImageFormat object.
|
25
|
+
#
|
26
|
+
def to_json(_options = {})
|
27
|
+
json_array = {}
|
28
|
+
json_array['multiPage'] = @multi_page
|
29
|
+
json_array['colorFormat'] = @color_format # Assuming TiffColorFormat has implemented to_json method.
|
30
|
+
|
31
|
+
JSON.pretty_generate(json_array)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require_relative "TiffColorFormat"
|
2
|
+
require_relative "ColorFormatType"
|
3
|
+
|
4
|
+
module DynamicPDFApi
|
5
|
+
#
|
6
|
+
# Represents indexed color format for TIFF.
|
7
|
+
#
|
8
|
+
class TiffIndexedColorFormat < TiffColorFormat
|
9
|
+
attr_accessor :quantization_algorithm # Gets or sets the QuantizationAlgorithm for TIFF.
|
10
|
+
attr_accessor :dithering_percent # Gets or sets the dithering percentage for TIFF.
|
11
|
+
attr_accessor :dithering_algorithm # Gets or sets the DitheringAlgorithm for TIFF.
|
12
|
+
|
13
|
+
#
|
14
|
+
# Initializes a new instance of the TiffIndexedColorFormat class with indexed color format type.
|
15
|
+
#
|
16
|
+
def initialize
|
17
|
+
super(ColorFormatType::Indexed)
|
18
|
+
@quantization_algorithm = nil
|
19
|
+
@dithering_percent = nil
|
20
|
+
@dithering_algorithm = nil
|
21
|
+
end
|
22
|
+
|
23
|
+
#
|
24
|
+
# Returns a JSON representation of the TiffIndexedColorFormat object.
|
25
|
+
#
|
26
|
+
# @return [String] JSON string representing the TiffIndexedColorFormat object.
|
27
|
+
#
|
28
|
+
def to_json(_options = {})
|
29
|
+
json_array = {}
|
30
|
+
json_array['quantizationAlgorithm'] = @quantization_algorithm
|
31
|
+
json_array['ditheringPercent'] = @dithering_percent
|
32
|
+
json_array['ditheringAlgorithm'] = @dithering_algorithm
|
33
|
+
|
34
|
+
JSON.pretty_generate(json_array)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require_relative "TiffColorFormat"
|
2
|
+
require_relative "ColorFormatType"
|
3
|
+
|
4
|
+
module DynamicPDFApi
|
5
|
+
#
|
6
|
+
# Represents monochrome color format for TIFF with black threshold and compression type.
|
7
|
+
#
|
8
|
+
class TiffMonochromeColorFormat < TiffColorFormat
|
9
|
+
attr_accessor :black_threshold # Gets or sets the black threshold for monochrome TIFF.
|
10
|
+
attr_accessor :compression_type # Gets or sets the CompressionType for monochrome TIFF.
|
11
|
+
attr_accessor :dithering_percent # Gets or sets the dithering percentage for TIFF.
|
12
|
+
attr_accessor :dithering_algorithm # Gets or sets the DitheringAlgorithm for TIFF.
|
13
|
+
|
14
|
+
#
|
15
|
+
# Initializes a new instance of the TiffMonochromeColorFormat class with monochrome color format type.
|
16
|
+
#
|
17
|
+
def initialize
|
18
|
+
super(ColorFormatType::Monochrome)
|
19
|
+
@black_threshold = nil
|
20
|
+
@compression_type = nil
|
21
|
+
@dithering_percent = nil
|
22
|
+
@dithering_algorithm = nil
|
23
|
+
end
|
24
|
+
|
25
|
+
#
|
26
|
+
# Returns a JSON representation of the TiffMonochromeColorFormat object.
|
27
|
+
#
|
28
|
+
# @return [String] JSON string representing the TiffMonochromeColorFormat object.
|
29
|
+
#
|
30
|
+
def to_json(_options = {})
|
31
|
+
json_array = {}
|
32
|
+
json_array['blackThreshold'] = @black_threshold
|
33
|
+
json_array['compressionType'] = @compression_type
|
34
|
+
json_array['ditheringPercent'] = @dithering_percent
|
35
|
+
json_array['ditheringAlgorithm'] = @dithering_algorithm
|
36
|
+
|
37
|
+
JSON.pretty_generate(json_array)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|