add pdf/a-3b

This commit is contained in:
Pete Matsyburka
2025-07-10 12:13:27 +03:00
parent 0ff87383d0
commit 82a7df5e3f
4 changed files with 34 additions and 1 deletions
+4
View File
@@ -88,6 +88,10 @@ module Docuseal
true
end
def pdf_format
@pdf_format ||= ENV['PDF_FORMAT'].to_s.downcase
end
def trusted_certs
@trusted_certs ||=
ENV['TRUSTED_CERTS'].to_s.gsub('\\n', "\n").split("\n\n").map do |base64|
+6 -1
View File
@@ -81,7 +81,12 @@ module Submissions
end
composer = HexaPDF::Composer.new(skip_page_creation: true)
composer.document.task(:pdfa) if FONT_NAME == 'GoNotoKurrent'
if Docuseal.pdf_format == 'pdf/a-3b'
composer.document.task(:pdfa, level: '3b')
elsif FONT_NAME == 'GoNotoKurrent'
composer.document.task(:pdfa)
end
composer.document.config['font.map'] = {
'Helvetica' => {
@@ -17,6 +17,11 @@ module Submissions
pdf.trailer.info[:Creator] = "#{Docuseal.product_name} (#{Docuseal::PRODUCT_URL})"
if Docuseal.pdf_format == 'pdf/a-3b'
pdf.task(:pdfa, level: '3b')
pdf.config['font.map'] = GenerateResultAttachments::PDFA_FONT_MAP
end
if pkcs
sign_params = {
reason: Submissions::GenerateResultAttachments.single_sign_reason(submitter),
@@ -30,6 +30,13 @@ module Submissions
bold_italic: FONT_BOLD_ITALIC_NAME
}.freeze
PDFA_FONT_VARIANS = {
none: FONT_NAME,
bold: FONT_BOLD_NAME,
italic: FONT_NAME,
bold_italic: FONT_BOLD_NAME
}.freeze
SIGN_REASON = 'Signed by %<name>s with DocuSeal.com'
RTL_REGEXP = TextUtils::RTL_REGEXP
@@ -48,6 +55,13 @@ module Submissions
'Courier' => 1.6
}.freeze
PDFA_FONT_MAP = {
FONT_NAME => PDFA_FONT_VARIANS,
'Helvetica' => PDFA_FONT_VARIANS,
'Times' => PDFA_FONT_VARIANS,
'Courier' => PDFA_FONT_VARIANS
}.freeze
MISSING_GLYPH_REPLACE = {
'▪' => '-',
'✔️' => 'V',
@@ -599,6 +613,11 @@ module Submissions
pdf.trailer.info[:Creator] = info_creator
if Docuseal.pdf_format == 'pdf/a-3b'
pdf.task(:pdfa, level: '3b')
pdf.config['font.map'] = PDFA_FONT_MAP
end
sign_reason = fetch_sign_reason(submitter)
if sign_reason && pkcs