-
Notifications
You must be signed in to change notification settings - Fork 95
Debugging AcroForm warnings #26321
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Debugging AcroForm warnings #26321
Changes from 3 commits
616f109
4971796
e22c9d0
9290233
9e7a930
5b83dfe
9938cb4
e6bf821
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -64,6 +64,10 @@ def build_form_data(data) | |
| end | ||
|
|
||
| def fill_and_write_pdf(form_data, output_path, email_delivery_failure) | ||
| if Flipper.enabled?(:acroform_debug_logs) | ||
| Rails.logger.info("DecisionReviews::PdfTemplateStamper #{@template_path}") | ||
| end | ||
|
Comment on lines
+67
to
+69
|
||
|
|
||
| doc = HexaPDF::Document.open(@template_path) | ||
|
|
||
| fill_form_fields(doc, form_data, email_delivery_failure) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -43,7 +43,10 @@ def self.stamp_signature(pdf_path, form_data) | |
| # @param pdf_path [String] Path to the PDF template | ||
| # @return [Hash, nil] Coordinates hash of the form | ||
| # `{ x: Float, y: Float, page_number: Integer }` or nil on failure | ||
| def self.signature_overlay_coordinates(pdf_path = TEMPLATE) | ||
| def self.signature_overlay_coordinates(pdf_path = TEMPLATE) # rubocop:disable Metrics/MethodLength | ||
| if Flipper.enabled?(:acroform_debug_logs) | ||
| Rails.logger.info("IncreaseCompensation::PdfStamper HexaPDF template: #{pdf_path}") | ||
| end | ||
|
Comment on lines
+47
to
+49
|
||
| doc = HexaPDF::Document.open(pdf_path) | ||
| return unless doc.validate(auto_correct: false) | ||
|
|
||
|
|
@@ -71,7 +74,7 @@ def self.signature_overlay_coordinates(pdf_path = TEMPLATE) | |
| end | ||
|
|
||
| def self.signature_text_for(form_data) | ||
| form_data['statementOfTruthSignature'].presence || | ||
| form_data['statement_of_truth_signature'].presence || | ||
|
RachalCassity marked this conversation as resolved.
Outdated
|
||
| form_data['signature'].presence || | ||
| veteran_full_name(form_data) | ||
| end | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -150,9 +150,30 @@ def merge_fields(_options = {}) | |
| # @param pdf_path [String] Path to the PDF template | ||
| # @return [Hash, nil] Coordinates hash of the form | ||
| # `{ x: Float, y: Float, page_number: Integer }` or nil on failure | ||
| def self.signature_overlay_coordinates(pdf_path) | ||
| def self.signature_overlay_coordinates(pdf_path) # rubocop:disable Metrics/MethodLength | ||
| if Flipper.enabled?(:acroform_debug_logs) | ||
| Rails.logger.info("MedicalExpenseReports::PdfFill::Va21p8416 HexaPDF template: #{pdf_path}") | ||
| end | ||
|
|
||
| doc = HexaPDF::Document.open(pdf_path) | ||
| field = doc.acro_form&.field_by_name(SIGNATURE_FIELD_NAME) | ||
| form = doc.acro_form | ||
| raise 'No AcroForm found in PDF template.' if form.nil? | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe we could put this inside the flipper since it is changing behavior?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let me revert that change |
||
|
|
||
| if Flipper.enabled?(:acroform_debug_logs) | ||
| # Find problematic fields | ||
| problematic_fields = form.each_field.select do |field| | ||
| field.field_type == :Btn && field[:AP].nil? | ||
| end | ||
|
|
||
| if problematic_fields.any? | ||
| Rails.logger.warn("Template #{template_path} has #{problematic_fields.size} fields missing AP") | ||
|
RachalCassity marked this conversation as resolved.
Outdated
|
||
| problematic_fields.each do |field| | ||
| Rails.logger.warn(" - Field: #{field.full_field_name}") | ||
| end | ||
| end | ||
| end | ||
|
RachalCassity marked this conversation as resolved.
Outdated
|
||
|
|
||
| field = form&.field_by_name(SIGNATURE_FIELD_NAME) | ||
| widget = field&.each_widget&.first | ||
| return unless widget | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -155,6 +155,10 @@ def self.signature_overlay_coordinates(pdf_path = TEMPLATE) | |
| end | ||
|
|
||
| def self.signature_overlay_coordinates_for(pdf_path) | ||
| if Flipper.enabled?(:acroform_debug_logs) | ||
| Rails.logger.info("SurivorsBenefits::PdfFill::Va21p534ez HexaPDF template: #{pdf_path}") | ||
|
RachalCassity marked this conversation as resolved.
Outdated
|
||
| end | ||
|
Comment on lines
+158
to
+160
|
||
|
|
||
| HexaPDF::Document.open(pdf_path) do |doc| | ||
| field = doc.acro_form&.field_by_name(SIGNATURE_FIELD_NAME) | ||
| widget = field&.each_widget&.first | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new logging behavior when the acroform_debug_logs feature flag is enabled lacks test coverage. The existing tests for fill_form_with_hexapdf don't verify this logging behavior. Add tests that verify the logging occurs when the flag is enabled and doesn't occur when disabled, following the pattern established in the codebase for feature flag testing.