From bd7f12d1d1ba68d93c440e21ecc2010d95859ef9 Mon Sep 17 00:00:00 2001 From: iozeey Date: Mon, 9 Oct 2023 15:53:54 +0500 Subject: [PATCH] adding redacting box on submitter pdf --- lib/submissions/generate_result_attachments.rb | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/submissions/generate_result_attachments.rb b/lib/submissions/generate_result_attachments.rb index 44dbf0f8..4278b740 100644 --- a/lib/submissions/generate_result_attachments.rb +++ b/lib/submissions/generate_result_attachments.rb @@ -52,7 +52,9 @@ module Submissions value = submitter.values[field['uuid']] - next if Array.wrap(value).compact_blank.blank? + if !field['type']=='redact' + next if Array.wrap(value).compact_blank.blank? + end canvas = page.canvas(type: :overlay) canvas.font(FONT_NAME, size: font_size) @@ -149,6 +151,15 @@ module Submissions .draw(canvas, ((area['x'] * width) + (cell_width * index)), height - (area['y'] * height)) end + when 'redact' + x = area['x'] * width + y = height - (area['y'] * height) - (area['h'] * height) + w = area['w'] * width + h = area['h'] * height + + canvas.fill_color(0, 0, 0) # Set fill color to black + canvas.rectangle(x, y, w, h) + canvas.fill else value = I18n.l(Date.parse(value), format: :default, locale: account.locale) if field['type'] == 'date' @@ -260,7 +271,7 @@ module Submissions page.box.height = attachment.metadata['height'] * scale page.canvas.image( - StringIO.new(attachment.preview_images.first.download), + StringIO.new(attachment.preview_secured_images.first.download), at: [0, 0], width: page.box.width, height: page.box.height