You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
docuseal/config/initializers/hexapdf.rb

64 lines
1.6 KiB

# frozen_string_literal: true
module HexaPDF
module Encryption
class SecurityHandler
def encrypt_string(str, obj)
return str.dup if str.empty? || obj == document.trailer[:Encrypt] || obj.type == :XRef ||
(obj.type == :Sig && obj[:Contents].equal?(str))
key = object_key(obj.oid, obj.gen, string_algorithm)
string_algorithm.encrypt(key, str).dup
end
end
end
module Type
# fix NoMethodError: undefined method `field_value' for #<HexaPDF::Type::AcroForm::Field
module AcroForm
class Field
def field_value
''
end
def terminal_field?
kids = self[:Kids]
# rubocop:disable Rails/Blank
kids.nil? || kids.empty? || kids.none? { |kid| kid&.key?(:T) }
# rubocop:enable Rails/Blank
end
end
end
# comparison of Integer with HexaPDF::PDFArray failed
class CIDFont < Font
private
def widths
cache(:widths) do
result = {}
index = 0
array = self[:W] || []
while index < array.size
entry = array[index]
value = array[index + 1]
if value.is_a?(Array) || value.is_a?(HexaPDF::PDFArray)
value.each_with_index { |width, i| result[entry + i] = width }
index += 2
else
width = array[index + 2]
entry.upto(value) { |cid| result[cid] = width }
index += 3
end
end
result
end
end
end
end
end