dynamicpdf_api 1.0.1 → 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/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 +31 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6f42bc787613e44286e726d180adfc0ea445d5398dfe16cedc82c493fc4ccd1a
|
4
|
+
data.tar.gz: de16d1e726916f97f16113f877b39fae03e86d412af0adbdb993e5a4bfff0ec7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce716f34048b25deb919ba964523acb9fffc6933e646b8f0286d9995019541284fa2b0be5bf7aaa58ccf6303557ba15e6795306a8634ca01ff43a10805af5720
|
7
|
+
data.tar.gz: 559e545b54529731b213a4a12b47c15717addefd878d447eeba751740f2cef2fc685624396e17564c315be32caaad62efa0fe4179f2510b6557e65d1534b1854
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module DynamicPDFApi
|
2
|
+
require_relative 'ColorFormat'
|
3
|
+
require_relative 'ColorFormatType'
|
4
|
+
|
5
|
+
#
|
6
|
+
# Base class for BMP color formats
|
7
|
+
#
|
8
|
+
class BmpColorFormat < ColorFormat
|
9
|
+
#
|
10
|
+
# Creates a new BmpColorFormat object with the given type.
|
11
|
+
#
|
12
|
+
def initialize(type)
|
13
|
+
if type != ColorFormatType::Monochrome
|
14
|
+
@type = ColorFormatType::RGB
|
15
|
+
else
|
16
|
+
@type = type
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module DynamicPDFApi
|
2
|
+
require_relative 'ImageFormat'
|
3
|
+
require_relative 'ImageFormatType'
|
4
|
+
|
5
|
+
#
|
6
|
+
# Represents BMP image format with color format.
|
7
|
+
#
|
8
|
+
class BmpImageFormat < ImageFormat
|
9
|
+
attr_accessor :color_format # Gets or sets the BmpColorFormat for BMP.
|
10
|
+
|
11
|
+
#
|
12
|
+
# Initializes a new instance of the BmpImageFormat class.
|
13
|
+
#
|
14
|
+
def initialize
|
15
|
+
super(ImageFormatType::BMP)
|
16
|
+
@color_format = nil
|
17
|
+
end
|
18
|
+
|
19
|
+
#
|
20
|
+
# Returns a JSON representation of the BmpImageFormat object.
|
21
|
+
#
|
22
|
+
# @return [String] JSON string representing the BmpImageFormat object.
|
23
|
+
#
|
24
|
+
def to_json(_options = {})
|
25
|
+
json_array = {}
|
26
|
+
json_array['type'] = 'bmp'
|
27
|
+
|
28
|
+
json_array['colorFormat'] = @color_format
|
29
|
+
JSON.pretty_generate(json_array)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module DynamicPDFApi
|
2
|
+
require_relative 'BmpColorFormat'
|
3
|
+
require_relative 'ColorFormatType'
|
4
|
+
|
5
|
+
|
6
|
+
#
|
7
|
+
# Represents monochrome color format for BMP.
|
8
|
+
#
|
9
|
+
class BmpMonochromeColorFormat < BmpColorFormat
|
10
|
+
attr_accessor :black_threshold # Gets or sets the black threshold for monochrome BMP, ranges from 0-255.
|
11
|
+
attr_accessor :dithering_percent # Gets or sets the dithering percentage for BMP.
|
12
|
+
attr_accessor :dithering_algorithm # Gets or sets the dithering algorithm for BMP.
|
13
|
+
|
14
|
+
#
|
15
|
+
# Creates object for monochrome color format for BMP image format.
|
16
|
+
#
|
17
|
+
def initialize
|
18
|
+
super(ColorFormatType::Monochrome)
|
19
|
+
@black_threshold = nil
|
20
|
+
@dithering_percent = nil
|
21
|
+
@dithering_algorithm = nil
|
22
|
+
end
|
23
|
+
|
24
|
+
#
|
25
|
+
# Returns a JSON representation of the BmpMonochromeColorFormat object.
|
26
|
+
#
|
27
|
+
# @return [String] JSON string representing the BmpMonochromeColorFormat object.
|
28
|
+
#
|
29
|
+
def to_json(_options = {})
|
30
|
+
json_array = {}
|
31
|
+
json_array['blackThreshold'] = @black_threshold
|
32
|
+
json_array['ditheringPercent'] = @dithering_percent
|
33
|
+
json_array['ditheringAlgorithm'] = @dithering_algorithm
|
34
|
+
JSON.pretty_generate(json_array)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module DynamicPDFApi
|
2
|
+
#
|
3
|
+
# Base class for all color formats.
|
4
|
+
#
|
5
|
+
class ColorFormat
|
6
|
+
#
|
7
|
+
# Initializes a new instance of ColorFormat.
|
8
|
+
#
|
9
|
+
def initialize
|
10
|
+
@type = nil
|
11
|
+
end
|
12
|
+
|
13
|
+
#
|
14
|
+
# Gets or sets the color format type.
|
15
|
+
#
|
16
|
+
attr_accessor :type
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module DynamicPDFApi
|
2
|
+
#
|
3
|
+
# Enum representing color formats.
|
4
|
+
#
|
5
|
+
class ColorFormatType
|
6
|
+
#
|
7
|
+
# RGB color format.
|
8
|
+
#
|
9
|
+
RGB = :Rgb.freeze
|
10
|
+
|
11
|
+
#
|
12
|
+
# RGBA color format.
|
13
|
+
#
|
14
|
+
RGBA = :Rgba.freeze
|
15
|
+
|
16
|
+
#
|
17
|
+
# Grayscale color format.
|
18
|
+
#
|
19
|
+
Grayscale = :Grayscale.freeze
|
20
|
+
|
21
|
+
#
|
22
|
+
# Monochrome color format.
|
23
|
+
#
|
24
|
+
Monochrome = :Monochrome.freeze
|
25
|
+
|
26
|
+
#
|
27
|
+
# Indexed color format.
|
28
|
+
#
|
29
|
+
Indexed = :Indexed.freeze
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module DynamicPDFApi
|
2
|
+
#
|
3
|
+
# Enum representing compression types.
|
4
|
+
#
|
5
|
+
class CompressionType
|
6
|
+
#
|
7
|
+
# CCIT Group 3 compression.
|
8
|
+
#
|
9
|
+
CcitGroup3 = :CcitGroup3.freeze
|
10
|
+
|
11
|
+
#
|
12
|
+
# CCIT Group 4 compression.
|
13
|
+
#
|
14
|
+
CcitGroup4 = :CcitGroup4.freeze
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module DynamicPDFApi
|
2
|
+
#
|
3
|
+
# Enum representing dithering algorithms.
|
4
|
+
#
|
5
|
+
class DitheringAlgorithm
|
6
|
+
#
|
7
|
+
# Floyd-Steinberg dithering algorithm.
|
8
|
+
#
|
9
|
+
FloydSteinberg = :FloydSteinberg.freeze
|
10
|
+
|
11
|
+
#
|
12
|
+
# Bayer dithering algorithm.
|
13
|
+
#
|
14
|
+
Bayer = :Bayer.freeze
|
15
|
+
|
16
|
+
#
|
17
|
+
# No dithering.
|
18
|
+
#
|
19
|
+
None = :None.freeze
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module DynamicPDFApi
|
2
|
+
require_relative "ImageSize"
|
3
|
+
require_relative "ImageSizeType"
|
4
|
+
#
|
5
|
+
# Represents an image size defined by DPI (Dots Per Inch).
|
6
|
+
#
|
7
|
+
class DpiImageSize < ImageSize
|
8
|
+
attr_accessor :horizontal_dpi # Gets or sets the horizontal DPI (Dots Per Inch) of the image.
|
9
|
+
attr_accessor :vertical_dpi # Gets or sets the vertical DPI (Dots Per Inch) of the image.
|
10
|
+
|
11
|
+
#
|
12
|
+
# Initializes a new instance of the DpiImageSize class and sets the image size type to DPI.
|
13
|
+
#
|
14
|
+
def initialize
|
15
|
+
super
|
16
|
+
@horizontal_dpi = nil
|
17
|
+
@vertical_dpi = nil
|
18
|
+
@type = ImageSizeType::Dpi
|
19
|
+
end
|
20
|
+
|
21
|
+
#
|
22
|
+
# Returns a JSON representation of the DpiImageSize object.
|
23
|
+
#
|
24
|
+
# @return [String] JSON string representing the DpiImageSize object.
|
25
|
+
#
|
26
|
+
def to_json(_options = {})
|
27
|
+
json_array = {}
|
28
|
+
json_array['type'] = 'dpi'
|
29
|
+
|
30
|
+
json_array['horizontalDpi'] = @horizontal_dpi
|
31
|
+
json_array['verticalDpi'] = @vertical_dpi
|
32
|
+
|
33
|
+
JSON.pretty_generate(json_array)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module DynamicPDFApi
|
2
|
+
require_relative "ImageSize"
|
3
|
+
require_relative "ImageSizeType"
|
4
|
+
|
5
|
+
|
6
|
+
#
|
7
|
+
# Represents an image size with fixed dimensions.
|
8
|
+
#
|
9
|
+
class FixedImageSize < ImageSize
|
10
|
+
attr_accessor :width # Gets or sets the width of the image.
|
11
|
+
attr_accessor :height # Gets or sets the height of the image.
|
12
|
+
attr_accessor :unit # Gets or sets the unit of measurement ImageSizeUnit for the width and height.
|
13
|
+
|
14
|
+
#
|
15
|
+
# Initializes a new instance of the FixedImageSize class and sets the image size type to Fixed.
|
16
|
+
#
|
17
|
+
def initialize
|
18
|
+
super()
|
19
|
+
@type = ImageSizeType::Fixed
|
20
|
+
@width = nil
|
21
|
+
@height = nil
|
22
|
+
@unit = nil
|
23
|
+
end
|
24
|
+
|
25
|
+
#
|
26
|
+
# Returns a JSON representation of the FixedImageSize object.
|
27
|
+
#
|
28
|
+
# @return [String] JSON string representing the FixedImageSize object.
|
29
|
+
#
|
30
|
+
def to_json(_options = {})
|
31
|
+
json_array = {}
|
32
|
+
json_array['type'] = 'fixed'
|
33
|
+
json_array['width'] = @width
|
34
|
+
json_array['height'] = @height
|
35
|
+
json_array['unit'] = @unit
|
36
|
+
JSON.pretty_generate(json_array)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module DynamicPDFApi
|
2
|
+
require_relative "ImageFormatType"
|
3
|
+
require_relative "ImageFormat"
|
4
|
+
|
5
|
+
# Represents GIF image format with dithering properties.
|
6
|
+
#
|
7
|
+
class GifImageFormat < ImageFormat
|
8
|
+
attr_accessor :dithering_percent # Gets or sets the dithering percentage.
|
9
|
+
attr_accessor :dithering_algorithm # Gets or sets the dithering algorithm.
|
10
|
+
|
11
|
+
#
|
12
|
+
# Initializes a new instance of the GifImageFormat class and sets the image format type to GIF.
|
13
|
+
#
|
14
|
+
def initialize
|
15
|
+
super(ImageFormatType::GIF)
|
16
|
+
@dithering_percent = nil
|
17
|
+
@dithering_algorithm = nil
|
18
|
+
end
|
19
|
+
|
20
|
+
#
|
21
|
+
# Returns a JSON representation of the GifImageFormat object.
|
22
|
+
#
|
23
|
+
# @return [String] JSON string representing the GifImageFormat object.
|
24
|
+
#
|
25
|
+
def to_json(_options = {})
|
26
|
+
json_array = {}
|
27
|
+
json_array['ditheringPercent'] = @dithering_percent
|
28
|
+
json_array['ditheringAlgorithm'] = @dithering_algorithm
|
29
|
+
json_array['type'] = 'gif'
|
30
|
+
JSON.pretty_generate(json_array)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module DynamicPDFApi
|
2
|
+
#
|
3
|
+
# Base class for image formats.
|
4
|
+
#
|
5
|
+
class ImageFormat
|
6
|
+
#
|
7
|
+
# Gets the image format type.
|
8
|
+
#
|
9
|
+
attr_reader :type
|
10
|
+
|
11
|
+
#
|
12
|
+
# Initializes a new instance of ImageFormat with the specified type.
|
13
|
+
#
|
14
|
+
# @param type [Symbol] The type of the image format.
|
15
|
+
#
|
16
|
+
def initialize(type)
|
17
|
+
@type = type
|
18
|
+
end
|
19
|
+
|
20
|
+
#
|
21
|
+
# Returns a JSON representation of the ImageFormat object.
|
22
|
+
#
|
23
|
+
# @return [String] JSON string representing the ImageFormat object.
|
24
|
+
#
|
25
|
+
def to_json(_options = {})
|
26
|
+
json_array = {}
|
27
|
+
json_array['type'] = @type
|
28
|
+
JSON.pretty_generate(json_array)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module DynamicPDFApi
|
2
|
+
#
|
3
|
+
# Enum representing supported image formats.
|
4
|
+
#
|
5
|
+
class ImageFormatType
|
6
|
+
#
|
7
|
+
# JPEG image format.
|
8
|
+
#
|
9
|
+
JPEG = :JPEG.freeze
|
10
|
+
|
11
|
+
#
|
12
|
+
# GIF image format.
|
13
|
+
#
|
14
|
+
GIF = :GIF.freeze
|
15
|
+
|
16
|
+
#
|
17
|
+
# BMP image format.
|
18
|
+
#
|
19
|
+
BMP = :BMP.freeze
|
20
|
+
|
21
|
+
#
|
22
|
+
# PNG image format.
|
23
|
+
#
|
24
|
+
PNG = :PNG.freeze
|
25
|
+
|
26
|
+
#
|
27
|
+
# TIFF image format.
|
28
|
+
#
|
29
|
+
TIFF = :TIFF.freeze
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module DynamicPDFApi
|
2
|
+
#
|
3
|
+
# Base class for image size types.
|
4
|
+
#
|
5
|
+
class ImageSize
|
6
|
+
attr_accessor :type # Type of the image size.
|
7
|
+
|
8
|
+
#
|
9
|
+
# Initializes a new instance of the ImageSize class.
|
10
|
+
#
|
11
|
+
def initialize
|
12
|
+
@type = nil
|
13
|
+
end
|
14
|
+
|
15
|
+
#
|
16
|
+
# Returns a JSON representation of the ImageSize object.
|
17
|
+
#
|
18
|
+
# @return [String] JSON string representing the ImageSize object.
|
19
|
+
#
|
20
|
+
def to_json(_options = {})
|
21
|
+
json_array = {}
|
22
|
+
json_array['type'] = @type
|
23
|
+
JSON.pretty_generate(json_array)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module DynamicPDFApi
|
2
|
+
#
|
3
|
+
# Enum specifying the type of image size.
|
4
|
+
#
|
5
|
+
class ImageSizeType
|
6
|
+
#
|
7
|
+
# DPI-based image size.
|
8
|
+
#
|
9
|
+
Dpi = :Dpi.freeze
|
10
|
+
|
11
|
+
#
|
12
|
+
# Fixed image size.
|
13
|
+
#
|
14
|
+
Fixed = :Fixed.freeze
|
15
|
+
|
16
|
+
#
|
17
|
+
# Image size that fits within a given maximum size.
|
18
|
+
#
|
19
|
+
Max = :Max.freeze
|
20
|
+
|
21
|
+
#
|
22
|
+
# Percentage-based image size.
|
23
|
+
#
|
24
|
+
Percentage = :Percentage.freeze
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module DynamicPDFApi
|
2
|
+
#
|
3
|
+
# Specifies the unit of measurement for image size.
|
4
|
+
#
|
5
|
+
class ImageSizeUnit
|
6
|
+
#
|
7
|
+
# Millimeter unit of measurement.
|
8
|
+
#
|
9
|
+
Millimeter = :Millimeter.freeze
|
10
|
+
|
11
|
+
#
|
12
|
+
# Inch unit of measurement.
|
13
|
+
#
|
14
|
+
Inch = :Inch.freeze
|
15
|
+
|
16
|
+
#
|
17
|
+
# Point unit of measurement.
|
18
|
+
#
|
19
|
+
Point = :Point.freeze
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module DynamicPDFApi
|
2
|
+
require_relative "ImageFormat"
|
3
|
+
require_relative "ImageFormatType"
|
4
|
+
|
5
|
+
#
|
6
|
+
# Represents JPEG image format with quality.
|
7
|
+
#
|
8
|
+
class JpegImageFormat < ImageFormat
|
9
|
+
attr_accessor :quality # Gets or sets the quality of the JPEG image.
|
10
|
+
|
11
|
+
#
|
12
|
+
# Initializes a new instance of the JpegImageFormat class.
|
13
|
+
#
|
14
|
+
def initialize
|
15
|
+
super(ImageFormatType::JPEG)
|
16
|
+
@quality = nil
|
17
|
+
end
|
18
|
+
|
19
|
+
#
|
20
|
+
# Returns a JSON representation of the JpegImageFormat object.
|
21
|
+
#
|
22
|
+
# @return [String] JSON string representing the JpegImageFormat object.
|
23
|
+
#
|
24
|
+
def to_json(_options = {})
|
25
|
+
json_array = {}
|
26
|
+
json_array['type'] = 'jpeg'
|
27
|
+
json_array['quality'] = @quality
|
28
|
+
JSON.pretty_generate(json_array)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module DynamicPDFApi
|
2
|
+
require_relative "ImageSize"
|
3
|
+
require_relative "ImageSizeType"
|
4
|
+
|
5
|
+
#
|
6
|
+
# Represents an image size that fits within a specified maximum width and height.
|
7
|
+
#
|
8
|
+
class MaxImageSize < ImageSize
|
9
|
+
attr_accessor :max_width # Gets or sets the maximum width of the image.
|
10
|
+
attr_accessor :max_height # Gets or sets the maximum height of the image.
|
11
|
+
attr_accessor :unit # Gets or sets the unit of measurement for the maximum width and height.
|
12
|
+
|
13
|
+
#
|
14
|
+
# Initializes a new instance of the MaxImageSize class.
|
15
|
+
#
|
16
|
+
def initialize
|
17
|
+
super()
|
18
|
+
@max_width = nil
|
19
|
+
@max_height = nil
|
20
|
+
@unit = nil
|
21
|
+
@type = ImageSizeType::Max
|
22
|
+
end
|
23
|
+
|
24
|
+
#
|
25
|
+
# Returns a JSON representation of the MaxImageSize object.
|
26
|
+
#
|
27
|
+
# @return [String] JSON string representing the MaxImageSize object.
|
28
|
+
#
|
29
|
+
def to_json(_options = {})
|
30
|
+
json_array = {}
|
31
|
+
json_array['type'] = 'max'
|
32
|
+
json_array['maxWidth'] = @max_width
|
33
|
+
json_array['maxHeight'] = @max_height
|
34
|
+
json_array['unit'] = @unit
|
35
|
+
JSON.pretty_generate(json_array)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -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
|
data/lib/ruby_client/Outline.rb
CHANGED
data/lib/ruby_client/Pdf.rb
CHANGED
@@ -51,11 +51,30 @@ module DynamicPDFApi
|
|
51
51
|
# <param name="resourceName">The name of the resource.
|
52
52
|
def add_additional_resource(resourcePath, resourceName = nil)
|
53
53
|
if (resourceName == nil)
|
54
|
-
resourceName =
|
54
|
+
resourceName = File.basename(resourcePath)
|
55
55
|
end
|
56
|
+
additional_resource = AdditionalResource.new(resourcePath, resourceName)
|
57
|
+
@resources[resourceName] = additional_resource
|
58
|
+
# @additionalResources << additional_resource
|
59
|
+
end
|
56
60
|
|
57
|
-
|
58
|
-
|
61
|
+
def add_additional_resource_with_resourcedata(resourceData, additionalResourceType, resourceName)
|
62
|
+
type = ResourceType::PDF
|
63
|
+
case (additionalResourceType)
|
64
|
+
|
65
|
+
when AdditionalResourceType::FONT
|
66
|
+
type = ResourceType::FONT
|
67
|
+
when AdditionalResourceType::IMAGE
|
68
|
+
type = ResourceType::IMAGE
|
69
|
+
when AdditionalResourceType::PDF
|
70
|
+
type = ResourceType::PDF
|
71
|
+
when AdditionalResourceType::HTML
|
72
|
+
type = ResourceType::HTML
|
73
|
+
else
|
74
|
+
raise 'This type of resource not allowed'
|
75
|
+
end
|
76
|
+
additional_resource = AdditionalResource.new(resourceData, resourceName, type)
|
77
|
+
@additionalResources << additional_resource
|
59
78
|
end
|
60
79
|
|
61
80
|
attr_accessor :instructions
|
@@ -18,7 +18,7 @@ module DynamicPDFApi
|
|
18
18
|
@_form_fields = []
|
19
19
|
@_templates = {}
|
20
20
|
@_fonts = {}
|
21
|
-
@
|
21
|
+
@_out_lines = []
|
22
22
|
@_inputs = []
|
23
23
|
@_security = nil
|
24
24
|
@_flatten_all_form_fields = nil
|
@@ -84,8 +84,8 @@ module DynamicPDFApi
|
|
84
84
|
json_array['formFields'] = @_form_fields
|
85
85
|
end
|
86
86
|
|
87
|
-
if(
|
88
|
-
json_array['outlines'] = @
|
87
|
+
if(!@_out_lines._out_lines.empty?)
|
88
|
+
json_array['outlines'] = @_out_lines
|
89
89
|
end
|
90
90
|
if(indented)
|
91
91
|
JSON.pretty_generate(json_array)
|
data/lib/ruby_client/version.rb
CHANGED
data/lib/ruby_client.rb
CHANGED
@@ -115,6 +115,35 @@ require_relative "ruby_client/Elements/StackedGs1DataBarType.rb"
|
|
115
115
|
require_relative "ruby_client/Elements/TextBarcodeElement.rb"
|
116
116
|
require_relative "ruby_client/Elements/TextElement.rb"
|
117
117
|
require_relative "ruby_client/Elements/ValueType.rb"
|
118
|
+
require_relative "ruby_client/Imaging/ColorFormatType.rb"
|
119
|
+
require_relative "ruby_client/Imaging/CompressionType.rb"
|
120
|
+
require_relative "ruby_client/Imaging/DitheringAlgorithm.rb"
|
121
|
+
require_relative "ruby_client/Imaging/DpiImageSize.rb"
|
122
|
+
require_relative "ruby_client/Imaging/FixedImageSize.rb"
|
123
|
+
require_relative "ruby_client/Imaging/GifImageFormat.rb"
|
124
|
+
require_relative "ruby_client/Imaging/ImageFormat.rb"
|
125
|
+
require_relative "ruby_client/Imaging/ImageFormatType.rb"
|
126
|
+
require_relative "ruby_client/Imaging/ImageSize.rb"
|
127
|
+
require_relative "ruby_client/Imaging/ImageSizeType.rb"
|
128
|
+
require_relative "ruby_client/Imaging/ImageSizeUnit.rb"
|
129
|
+
require_relative "ruby_client/Imaging/JpegImageFormat.rb"
|
130
|
+
require_relative "ruby_client/Imaging/MaxImageSize.rb"
|
131
|
+
require_relative "ruby_client/Imaging/PercentageImageSize.rb"
|
132
|
+
require_relative "ruby_client/Imaging/PngColorFormat.rb"
|
133
|
+
require_relative "ruby_client/Imaging/PngImageFormat.rb"
|
134
|
+
require_relative "ruby_client/Imaging/PngIndexedColorFormat.rb"
|
135
|
+
require_relative "ruby_client/Imaging/PngMonochromeColorFormat.rb"
|
136
|
+
require_relative "ruby_client/Imaging/QuantizationAlgorithm.rb"
|
137
|
+
require_relative "ruby_client/Imaging/PdfImage.rb"
|
138
|
+
require_relative "ruby_client/Imaging/PdfImageResponse.rb"
|
139
|
+
require_relative "ruby_client/Imaging/TiffColorFormat.rb"
|
140
|
+
require_relative "ruby_client/Imaging/TiffImageFormat.rb"
|
141
|
+
require_relative "ruby_client/Imaging/TiffIndexedColorFormat.rb"
|
142
|
+
require_relative "ruby_client/Imaging/TiffMonochromeColorFormat.rb"
|
143
|
+
require_relative "ruby_client/Imaging/BmpColorFormat.rb"
|
144
|
+
require_relative "ruby_client/Imaging/BmpImageFormat.rb"
|
145
|
+
require_relative "ruby_client/Imaging/BmpMonochromeColorFormat.rb"
|
146
|
+
require_relative "ruby_client/Imaging/ColorFormat.rb"
|
118
147
|
|
119
148
|
module RubyClient
|
120
149
|
class Error < StandardError; end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dynamicpdf_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dynamicpdf
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-08-09 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A Ruby Client API that uses the DynamicPDF API to create, merge, split,
|
14
14
|
form fill, stamp, secure/encrypt PDF documents and convert word/Excel files to PDF.
|
@@ -91,6 +91,35 @@ files:
|
|
91
91
|
- lib/ruby_client/ImageInput.rb
|
92
92
|
- lib/ruby_client/ImageResource.rb
|
93
93
|
- lib/ruby_client/ImageResponse.rb
|
94
|
+
- lib/ruby_client/Imaging/BmpColorFormat.rb
|
95
|
+
- lib/ruby_client/Imaging/BmpImageFormat.rb
|
96
|
+
- lib/ruby_client/Imaging/BmpMonochromeColorFormat.rb
|
97
|
+
- lib/ruby_client/Imaging/ColorFormat.rb
|
98
|
+
- lib/ruby_client/Imaging/ColorFormatType.rb
|
99
|
+
- lib/ruby_client/Imaging/CompressionType.rb
|
100
|
+
- lib/ruby_client/Imaging/DitheringAlgorithm.rb
|
101
|
+
- lib/ruby_client/Imaging/DpiImageSize.rb
|
102
|
+
- lib/ruby_client/Imaging/FixedImageSize.rb
|
103
|
+
- lib/ruby_client/Imaging/GifImageFormat.rb
|
104
|
+
- lib/ruby_client/Imaging/ImageFormat.rb
|
105
|
+
- lib/ruby_client/Imaging/ImageFormatType.rb
|
106
|
+
- lib/ruby_client/Imaging/ImageSize.rb
|
107
|
+
- lib/ruby_client/Imaging/ImageSizeType.rb
|
108
|
+
- lib/ruby_client/Imaging/ImageSizeUnit.rb
|
109
|
+
- lib/ruby_client/Imaging/JpegImageFormat.rb
|
110
|
+
- lib/ruby_client/Imaging/MaxImageSize.rb
|
111
|
+
- lib/ruby_client/Imaging/PdfImage.rb
|
112
|
+
- lib/ruby_client/Imaging/PdfImageResponse.rb
|
113
|
+
- lib/ruby_client/Imaging/PercentageImageSize.rb
|
114
|
+
- lib/ruby_client/Imaging/PngColorFormat.rb
|
115
|
+
- lib/ruby_client/Imaging/PngImageFormat.rb
|
116
|
+
- lib/ruby_client/Imaging/PngIndexedColorFormat.rb
|
117
|
+
- lib/ruby_client/Imaging/PngMonochromeColorFormat.rb
|
118
|
+
- lib/ruby_client/Imaging/QuantizationAlgorithm.rb
|
119
|
+
- lib/ruby_client/Imaging/TiffColorFormat.rb
|
120
|
+
- lib/ruby_client/Imaging/TiffImageFormat.rb
|
121
|
+
- lib/ruby_client/Imaging/TiffIndexedColorFormat.rb
|
122
|
+
- lib/ruby_client/Imaging/TiffMonochromeColorFormat.rb
|
94
123
|
- lib/ruby_client/Input.rb
|
95
124
|
- lib/ruby_client/InputType.rb
|
96
125
|
- lib/ruby_client/JsonResponse.rb
|