|
|
|
@ -58,13 +58,15 @@ module Submissions
|
|
|
|
submitter.submission.template_schema.map do |item|
|
|
|
|
submitter.submission.template_schema.map do |item|
|
|
|
|
pdf = pdfs_index[item['attachment_uuid']]
|
|
|
|
pdf = pdfs_index[item['attachment_uuid']]
|
|
|
|
|
|
|
|
|
|
|
|
attachment = build_pdf_attachment(pdf:, submitter:, pkcs:, tsa_url:,
|
|
|
|
if original_documents.find { |a| a.uuid == item['attachment_uuid'] }.image?
|
|
|
|
uuid: item['attachment_uuid'],
|
|
|
|
pdf = normalize_image_pdf(pdf)
|
|
|
|
name: item['name'])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
image_pdfs << pdf if original_documents.find { |a| a.uuid == item['attachment_uuid'] }.image?
|
|
|
|
image_pdfs << pdf
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
attachment
|
|
|
|
build_pdf_attachment(pdf:, submitter:, pkcs:, tsa_url:,
|
|
|
|
|
|
|
|
uuid: item['attachment_uuid'],
|
|
|
|
|
|
|
|
name: item['name'])
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
return result_attachments.map { |e| e.tap(&:save!) } if image_pdfs.size < 2
|
|
|
|
return result_attachments.map { |e| e.tap(&:save!) } if image_pdfs.size < 2
|
|
|
|
@ -74,6 +76,8 @@ module Submissions
|
|
|
|
pdf.pages.each { |page| doc.pages << doc.import(page) }
|
|
|
|
pdf.pages.each { |page| doc.pages << doc.import(page) }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
images_pdf = normalize_image_pdf(images_pdf)
|
|
|
|
|
|
|
|
|
|
|
|
images_pdf_attachment =
|
|
|
|
images_pdf_attachment =
|
|
|
|
build_pdf_attachment(
|
|
|
|
build_pdf_attachment(
|
|
|
|
pdf: images_pdf,
|
|
|
|
pdf: images_pdf,
|
|
|
|
@ -590,6 +594,14 @@ module Submissions
|
|
|
|
pdf
|
|
|
|
pdf
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def normalize_image_pdf(pdf)
|
|
|
|
|
|
|
|
io = StringIO.new
|
|
|
|
|
|
|
|
pdf.write(io)
|
|
|
|
|
|
|
|
io.rewind
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HexaPDF::Document.new(io:)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def sign_reason(name)
|
|
|
|
def sign_reason(name)
|
|
|
|
format(SIGN_REASON, name:)
|
|
|
|
format(SIGN_REASON, name:)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|