process acro form fields

This commit is contained in:
Alex Turchyn
2024-06-22 13:16:22 +03:00
committed by Pete Matsyburka
parent 320fe02e35
commit 749043dfbb
10 changed files with 374 additions and 17 deletions
+4 -4
View File
@@ -9,17 +9,17 @@ module Templates
module_function
def call(template, params)
def call(template, params, extract_fields: false)
Array.wrap(params[:files].presence || params[:file]).map do |file|
if file.content_type.exclude?('image') && file.content_type != PDF_CONTENT_TYPE
next handle_file_types(template, file, params)
end
handle_pdf_or_image(template, file, file.read, params)
handle_pdf_or_image(template, file, file.read, params, extract_fields:)
end
end
def handle_pdf_or_image(template, file, document_data = nil, params = {})
def handle_pdf_or_image(template, file, document_data = nil, params = {}, extract_fields: false)
document_data ||= file.read
if file.content_type == PDF_CONTENT_TYPE
@@ -44,7 +44,7 @@ module Templates
document = template.documents.create!(blob:)
Templates::ProcessDocument.call(document, document_data)
Templates::ProcessDocument.call(document, document_data, extract_fields:)
end
def maybe_decrypt_pdf_or_raise(data, params)