Skip to content
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

Feature: Form Field types (PDF 1.7 Section 12.7.4) #23

Merged
merged 7 commits into from
Oct 22, 2023

Conversation

tingerrr
Copy link
Contributor

@tingerrr tingerrr commented Oct 21, 2023

This PR adds the writers and types for writing various types form fields.

  • Text Fields
  • Choice Fields
  • Button Fields
  • Signature Fields (Left out to reduce review surface to in turn ensure correct implementation)

@tingerrr
Copy link
Contributor Author

I once again went with a prefix based approach to make the specific functions for /V and /DV exist in tandem. I don't like this solution all that much, we can probably clean this up in the future by providing specialized writers for cases where dictionaries have specific fields for a specific subtype.

src/forms.rs Outdated Show resolved Hide resolved
src/forms.rs Outdated
Comment on lines 82 to 90
// TODO: the spec likely means the equivalent of unicode graphemes here
// for characters

/// Write the `/MaxLen` attribute to set the maximum length of the fields
/// text in characters. Only permissible on text fields.
pub fn text_max_len(&mut self, len: i32) -> &mut Self {
self.dict.pair(Name(b"MaxLen"), len);
self
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As noted here, I was looking for mentions of character in the spec and couldn't really find what they define to be a character, but I assume this is about what the user sees.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@reknih this is still relevant, unfortunately moving the code around has marked this as outdated.

@tingerrr tingerrr marked this pull request as ready for review October 21, 2023 13:12
@tingerrr
Copy link
Contributor Author

While this is marked as ready for review, there is still some work to do, like exporting the types and such.

Copy link
Member

@reknih reknih left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a huge section of the spec so there are bound to be some comments. You are making good progress.

src/forms.rs Show resolved Hide resolved
src/forms.rs Show resolved Hide resolved
src/forms.rs Outdated Show resolved Hide resolved
src/forms.rs Outdated Show resolved Hide resolved
src/forms.rs Outdated Show resolved Hide resolved
src/forms.rs Outdated Show resolved Hide resolved
src/forms.rs Outdated Show resolved Hide resolved
src/forms.rs Outdated Show resolved Hide resolved
src/forms.rs Outdated Show resolved Hide resolved
src/forms.rs Outdated Show resolved Hide resolved
@reknih reknih merged commit bb19bfd into typst:main Oct 22, 2023
1 check passed
@tingerrr tingerrr deleted the field-types branch October 24, 2023 16:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants