Skip to content

Commit

Permalink
Fix parsing of default appearance strings to handle invalid PDFs with…
Browse files Browse the repository at this point in the history
… symbolic DAs
  • Loading branch information
gettalong committed Aug 30, 2024
1 parent 0a0d894 commit 789a377
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
* [HexaPDF::Type::AcroForm::AppearanceGenerator] to work for files where check
boxes don't define the name of the on state
* [HexaPDF::Importer#import] to handle null values in all cases
* [HexaPDF::Type::AcroForm::VariableTextField] to handle parsing of invalid PDFs
with symbolic appearance strings


## 0.46.0 - 2024-08-11
Expand Down
2 changes: 1 addition & 1 deletion lib/hexapdf/type/acro_form/variable_text_field.rb
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def parse_default_appearance_string(widget = self)
raise HexaPDF::Error, "No default appearance string set"
end
end
self.class.parse_appearance_string(da)
self.class.parse_appearance_string(da.to_s)
end

end
Expand Down
5 changes: 5 additions & 0 deletions test/hexapdf/type/acro_form/test_variable_text_field.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@
@field.parse_default_appearance_string)
end

it "converts the /DA to a string in case an invalid PDF uses a Symbol" do
@field[:DA] = :"1 g /F1 20 Tf"
assert_equal([:F1, 20, @color], @field.parse_default_appearance_string)
end

it "fails if no /DA value is set and no default appearance string should be set" do
@doc.acro_form.delete(:DA)
@doc.config['acro_form.fallback_default_appearance'] = nil
Expand Down

0 comments on commit 789a377

Please sign in to comment.