Skip to content

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

Merged
reknih merged 7 commits into
typst:mainfrom
tingerrr:field-types
Oct 22, 2023
Merged

reknih merged 7 commits into
typst:mainfrom
tingerrr:field-types

Conversation

@tingerrr

@tingerrr tingerrr commented Oct 21, 2023 •

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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.

Comment thread src/forms.rs Resolved
Comment thread src/forms.rs
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor Author

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

@reknih reknih left a comment

Copy link
Copy Markdown
Member

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.

Comment thread src/forms.rs Resolved
Comment thread src/forms.rs Resolved
Comment thread src/forms.rs Resolved
Comment thread src/forms.rs Resolved
Comment thread src/forms.rs Resolved
Comment thread src/forms.rs Resolved
Comment thread src/forms.rs Resolved
Comment thread src/forms.rs Resolved
Comment thread src/forms.rs Resolved
Comment thread src/forms.rs Resolved
@PavanSamyak

Copy link
Copy Markdown

I'm new to typst can anyone guide me how to add interactive checkbox to pdf without postprossing

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.

3 participants