dynamicpdf_api 1.3.0 → 2.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a7ac0d6c7b3af40747eebd62d4bbe5312c47f7df899eeeace9e62baafd607f19
4
- data.tar.gz: 6f3448f2d9daa4d345109bb187797ad2f4f385b5225c6217159868e4d4e79bee
3
+ metadata.gz: 5427fc35251fa21f680fdba436398a94022ed793ce0a614d15be5712fc5801be
4
+ data.tar.gz: b079a50d26fc63e33089f3145e5e5d94ca2954e0a8ece78e73321dfc39ef0110
5
5
  SHA512:
6
- metadata.gz: 5666463e8fdfa35d273f72b1e13cced90e661054cfb772329869f77069303c28fe7bdfb802ff9dbe5db68aaab7b1b114377d78e0ad15f85e1350287a57f646c1
7
- data.tar.gz: 8536196f5815157f71fe925c4cd7879a1b09dc5e8ea1f8723d3e94207fbe927ab55b19a38cd9bb80c66a76b3bd4d17c9f6db3bfb4bb5543827fec8bbb59a12a1
6
+ metadata.gz: d1d477bc4deab58568ffc065d051a020dff8621fea17ad8fc76ee16322a47df37b0b370ecdbc23f4e2a21bb361577683ff5da328ccb0925497f94746206dd017
7
+ data.tar.gz: 486dbe03715475af148d3684d083b4c88493df7588cff4994d0c9838e22990e4b22f8d256c27084750b12094b41d480c9c932d4ab572fc0a6d492e3ec4a3c507
@@ -29,6 +29,7 @@ module DynamicPDFApi
29
29
  #
30
30
  attr_accessor :x_dimension
31
31
 
32
+ protected
32
33
  #
33
34
  # Gets or sets the value of the barcode.
34
35
  #
@@ -16,7 +16,7 @@ module DynamicPDFApi
16
16
  else
17
17
  super(value, placement, x_offset, y_offset)
18
18
  @_value_type = ValueType::BASE64_ENCODED_BYTES
19
- @value = Base64.encode64(value.pack('C*'))
19
+ @value = Base64.strict_encode64(value.pack('C*'))
20
20
  @placement = placement
21
21
  @x_offset = x_offset
22
22
  @y_offset = y_offset
@@ -10,12 +10,55 @@ module DynamicPDFApi
10
10
  @load_required = true
11
11
  @lock = Mutex.new
12
12
 
13
- # For Windows fonts
14
- windir = ENV["WINDIR"]
15
- if windir && !windir.empty?
16
- @path_to_fonts_resource_directory = File.join(windir, "Fonts")
17
- else
18
- @path_to_fonts_resource_directory = nil
13
+ def self.init(platform_override = nil)
14
+ begin
15
+
16
+ # -------- Windows --------
17
+ if RUBY_PLATFORM =~ /mswin|mingw|cygwin/
18
+ windir = ENV["WINDIR"]
19
+ if windir && !windir.empty?
20
+ path = File.join(windir, "Fonts")
21
+ @path_to_fonts_resource_directory = path if Dir.exist?(path)
22
+ end
23
+
24
+ # -------- macOS --------
25
+ elsif RUBY_PLATFORM =~ /darwin/
26
+ home = Dir.home rescue nil
27
+ paths = [
28
+ "/System/Library/Fonts",
29
+ "/Library/Fonts",
30
+ home ? File.join(home, "Library", "Fonts") : nil
31
+ ]
32
+
33
+ paths.each do |path|
34
+ next unless path
35
+ if Dir.exist?(path)
36
+ @path_to_fonts_resource_directory = path
37
+ break
38
+ end
39
+ end
40
+
41
+ # -------- Linux --------
42
+ elsif RUBY_PLATFORM =~ /linux/
43
+ home = Dir.home rescue nil
44
+ paths = [
45
+ "/usr/share/fonts",
46
+ "/usr/local/share/fonts",
47
+ home ? File.join(home, ".fonts") : nil,
48
+ home ? File.join(home, ".local", "share", "fonts") : nil
49
+ ]
50
+
51
+ paths.each do |path|
52
+ next unless path
53
+ if Dir.exist?(path)
54
+ @path_to_fonts_resource_directory = path
55
+ break
56
+ end
57
+ end
58
+ end
59
+ rescue e
60
+ puts "Error in getting the font: #{e.message}"
61
+ end
19
62
  end
20
63
 
21
64
  #
@@ -279,6 +322,8 @@ module DynamicPDFApi
279
322
  return unless @load_required
280
323
  loaded_any = false
281
324
 
325
+ init
326
+
282
327
  @lock.synchronize do
283
328
  if @path_to_fonts_resource_directory && !@path_to_fonts_resource_directory.empty?
284
329
  dir_Info = File.join(@path_to_fonts_resource_directory.gsub("\\", "/"), "*")
@@ -223,17 +223,20 @@ module DynamicPDFApi
223
223
  #
224
224
  # Returns a page_input object containing the input pdf.
225
225
  #
226
- # @param page_width [float] The width of the page.
227
- # @param page_height [float] The height of the page.
226
+ # @param size [String]|[Float] The size of the page or The width of the page.
227
+ # @param orientation [String]|[Float] The orientation of the page or The height of the page.
228
+ # @param margins [Float] The margins of the page.
228
229
  #
229
- # @return page_input page_input object.
230
+ # @return PageInput PageInput object.
230
231
  #
231
- def add_page(page_width = nil, page_height = nil)
232
- input = if !page_width.nil? && !page_height.nil?
233
- PageInput.new(page_width, page_height)
234
- else
235
- PageInput.new
236
- end
232
+ def add_page(size = nil, orientation = nil, margins = nil)
233
+ if (size.is_a?(String) || size.nil?) && (orientation.is_a?(String) || orientation.nil?)
234
+ input = PageInput.new(size, orientation, margins)
235
+ elsif (size.is_a?(Numeric)) && (orientation.is_a?(Numeric))
236
+ input = PageInput.new(size, orientation)
237
+ else
238
+ input = PageInput.new
239
+ end
237
240
  @inputs << input
238
241
  input
239
242
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RubyClient
4
- VERSION = "1.3.0"
4
+ VERSION = "2.0.0"
5
5
  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.3.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dynamicpdf
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-11-14 00:00:00.000000000 Z
11
+ date: 2026-02-18 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.