Skip to content

Commit

Permalink
fix pdf form flatten fields
Browse files Browse the repository at this point in the history
  • Loading branch information
omohokcoj committed May 26, 2024
1 parent 99bc46b commit 2605731
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions lib/submissions/generate_result_attachments.rb
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ def build_pdfs_index(submitter, flatten: true)

if flatten
begin
pdf.acro_form.create_appearances(force: true) if pdf.acro_form && pdf.acro_form[:NeedAppearances]
pdf.acro_form&.flatten
rescue StandardError => e
Rollbar.error(e) if defined?(Rollbar)
Expand Down
8 changes: 4 additions & 4 deletions lib/templates/process_document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,15 @@ def generate_pdf_preview_images(attachment, data)
end
end

def maybe_flatten_form(data, pdf, attachment)
def maybe_flatten_form(data, pdf)
return data if data.size > MAX_FLATTEN_FILE_SIZE
return data if pdf.acro_form.blank?
return data if attachment.record.account.account_configs
.find_or_initialize_by(key: AccountConfig::FLATTEN_RESULT_PDF_KEY).value == false

io = StringIO.new

pdf.acro_form&.flatten
pdf.acro_form.create_appearances(force: true) if pdf.acro_form[:NeedAppearances]
pdf.acro_form.flatten

pdf.write(io, incremental: false, validate: false)

io.string
Expand Down

0 comments on commit 2605731

Please sign in to comment.