diff --git a/app/javascript/draw.js b/app/javascript/draw.js
index 81ceccf5..c42c3c72 100644
--- a/app/javascript/draw.js
+++ b/app/javascript/draw.js
@@ -12,6 +12,10 @@ window.customElements.define('draw-signature', class extends HTMLElement {
this.pad = new SignaturePad(this.canvas)
+ if (this.dataset.color) {
+ this.pad.penColor = this.dataset.color
+ }
+
this.pad.addEventListener('endStroke', () => {
this.updateSubmitButtonVisibility()
})
diff --git a/app/javascript/submission_form/area.vue b/app/javascript/submission_form/area.vue
index 5d08ce75..6ae92c0c 100644
--- a/app/javascript/submission_form/area.vue
+++ b/app/javascript/submission_form/area.vue
@@ -408,6 +408,10 @@ export default {
style.lineHeight = `clamp(6pt, 2.0vw, ${parseInt(this.field.preferences.font_size) + 3}pt)`
}
+ if (this.field.preferences?.color) {
+ style.color = this.field.preferences.color
+ }
+
return style
}
},
diff --git a/app/javascript/submission_form/initials_step.vue b/app/javascript/submission_form/initials_step.vue
index 1241a952..5835c9e7 100644
--- a/app/javascript/submission_form/initials_step.vue
+++ b/app/javascript/submission_form/initials_step.vue
@@ -226,6 +226,10 @@ export default {
if (this.$refs.canvas) {
this.pad = new SignaturePad(this.$refs.canvas)
+ if (this.field.preferences?.color) {
+ this.pad.penColor = this.field.preferences.color
+ }
+
this.pad.addEventListener('beginStroke', () => {
this.isInitialsStarted = true
diff --git a/app/javascript/submission_form/signature_step.vue b/app/javascript/submission_form/signature_step.vue
index ffce4ab3..4a8fbe9c 100644
--- a/app/javascript/submission_form/signature_step.vue
+++ b/app/javascript/submission_form/signature_step.vue
@@ -423,6 +423,10 @@ export default {
if (this.$refs.canvas) {
this.pad = new SignaturePad(this.$refs.canvas)
+ if (this.field.preferences?.color) {
+ this.pad.penColor = this.field.preferences.color
+ }
+
this.pad.addEventListener('endStroke', () => {
this.isSignatureStarted = true
diff --git a/app/javascript/template_builder/area.vue b/app/javascript/template_builder/area.vue
index f18354c9..61439a78 100644
--- a/app/javascript/template_builder/area.vue
+++ b/app/javascript/template_builder/area.vue
@@ -175,6 +175,7 @@
-">
+<% color = field.dig('preferences', 'color') %>
+width: <%= area['w'] * 100 %>%; height: <%= area['h'] * 100 %>%; left: <%= area['x'] * 100 %>%; top: <%= area['y'] * 100 %>%; <%= "font-size: clamp(4pt, 1.6vw, #{field['preferences']['font_size']}pt); line-height: `clamp(6pt, 2.0vw, #{field['preferences']['font_size'].to_i + 3}pt)`" if field.dig('preferences', 'font_size') %>">
<% if field['type'] == 'signature' %>
diff --git a/app/views/submit_form_draw_signature/show.html.erb b/app/views/submit_form_draw_signature/show.html.erb
index 6518d0a7..967d824a 100644
--- a/app/views/submit_form_draw_signature/show.html.erb
+++ b/app/views/submit_form_draw_signature/show.html.erb
@@ -15,9 +15,10 @@
<%= render 'shared/posthog' if ENV['POSTHOG_TOKEN'] %>
-
+ <% field = (@submitter.submission.template_fields || @submitter.template.fields).find { |f| f['type'] == 'signature' && f['uuid'].starts_with?(params[:f]) } %>
+
<%= form_for '', url: submit_form_path(params[:slug]), html: { style: 'max-width: 900px; width: 100%; margin-bottom: 120px' }, method: :put do |f| %>
-
+
<%= t('draw_signature') %>
diff --git a/lib/submissions/generate_result_attachments.rb b/lib/submissions/generate_result_attachments.rb
index 3bc6a290..d552111d 100644
--- a/lib/submissions/generate_result_attachments.rb
+++ b/lib/submissions/generate_result_attachments.rb
@@ -179,6 +179,8 @@ module Submissions
font_size = preferences_font_size
font_size ||= (([page.box.width, page.box.height].min / A4_SIZE[0].to_f) * FONT_SIZE).to_i
+ fill_color = field.dig('preferences', 'color').presence
+
font = pdf.fonts.add(field.dig('preferences', 'font').presence || FONT_NAME)
value = submitter.values[field['uuid']]
@@ -380,6 +382,7 @@ module Submissions
next if char.blank?
text = HexaPDF::Layout::TextFragment.create(char, font:,
+ fill_color:,
font_size:)
line_height = layouter.fit([text], cell_width, height).lines.first.height
@@ -387,6 +390,7 @@ module Submissions
if preferences_font_size.blank? && line_height > (area['h'] * height)
text = HexaPDF::Layout::TextFragment.create(char,
font:,
+ fill_color:,
font_size: (font_size / 1.4).to_i)
line_height = layouter.fit([text], cell_width, height).lines.first.height
@@ -395,6 +399,7 @@ module Submissions
if preferences_font_size.blank? && line_height > (area['h'] * height)
text = HexaPDF::Layout::TextFragment.create(char,
font:,
+ fill_color:,
font_size: (font_size / 1.9).to_i)
line_height = layouter.fit([text], cell_width, height).lines.first.height
@@ -414,6 +419,7 @@ module Submissions
value = TextUtils.maybe_rtl_reverse(Array.wrap(value).join(', '))
text = HexaPDF::Layout::TextFragment.create(value, font:,
+ fill_color:,
font_size:)
lines = layouter.fit([text], area['w'] * width, height).lines
@@ -422,6 +428,7 @@ module Submissions
if preferences_font_size.blank? && box_height > (area['h'] * height) + 1
text = HexaPDF::Layout::TextFragment.create(value,
font:,
+ fill_color:,
font_size: (font_size / 1.4).to_i)
lines = layouter.fit([text], field['type'].in?(%w[date number]) ? width : area['w'] * width, height).lines
@@ -432,6 +439,7 @@ module Submissions
if preferences_font_size.blank? && box_height > (area['h'] * height) + 1
text = HexaPDF::Layout::TextFragment.create(value,
font:,
+ fill_color:,
font_size: (font_size / 1.9).to_i)
lines = layouter.fit([text], field['type'].in?(%w[date number]) ? width : area['w'] * width, height).lines