-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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
Basic AcroForms input controls rendering #6172
Conversation
ba370ae
to
090536e
Compare
Can anyone point me out how to parse/evaluate "a sequence of valid page-content graphics or text state operators that define such properties as the field’s text size and color" ? |
Let's keep things simple and avoid parsing appearance streams for now. The reason I say this is that this PR has a greater chance of being merged if it is smaller and therefore easier to review and test. We need to split the work here into several PRs and iterate on the issue. For instance, let this PR just be the basic AcroForms framework with basic fields, then a next PR for the other fields, and a next PR for annotation appearance streams. The latter is also affecting my work on the annotation layer, so we need to find out the best way to implement that according to the specification. |
e588320
to
92bee91
Compare
@timvandermeij Thanks for your suggestion. Can you review the changes? |
481331d
to
24228ce
Compare
@xlc would you mind splitting up this PR into smaller ones? Also see kind-off tracking bug #1459 |
@fbender How should I splitting this? This PR only implements text fields. I have more controls implemented in my other branch which depends on this. I will PR it when this is merged in. |
Fortunately most of my PR is already merged using smaller PRs (see #5218 (comment) for a complete explanation) and I hope to do the rest soon such that that PR is done. It should not block this PR too much, but we need to have more structure first before adding new annotation features (AcroForms from here, but also the video annotation PR). Part of my PR is the handling of flags in the base class such that subclasses do not need to implement that too (as I see some flag handling in this PR). I also feel that the elements processed here should be in a class that extends the Annotation base class as AcroForm elements are Widgets if I'm not mistaken. We should unify the handling of those somewhat better here. |
See e.g. @timvandermeij's answer:
This needs to be adapted to the new stuff implemented in #5218 first, of course. See e.g.
This somehow seems to contradict this statement:
@timvandermeij can you please clarify which changes you expect to be blocking this work? Would be nice if there are (merged or still unmerged) PRs (or implementation concepts/drafts) you can link to that will help @xlc in refactoring his code. |
I meant to say that there are no real dependencies on #5218 for this PR, but that this PR does need a bit more structure and clean-up. Examples:
I think the bottom line is that I'm not completely sure on what the best structure is. In the PDF specification, Adobe tends to label everything that does not belong to the other annotation types a Widget, but there are many kinds of Widgets (static text widgets, form widgets like buttons and fields, et cetera). I don't think intertwining them all in the code is a good idea: there has to be a clear distinction between form widgets and text widgets, for instance. Ideally every type of annotation, but also every subtype like FormWidgets or TextWidgets, are separate classes. Other ideas for a good structure are of course welcome. |
AFAIK, Widget annotations are form widgets. There is no static text widget (there is text annotation and free text annotation). Text Field widget is the interactive form widget you can enter text. So I don't think we need distinction between form widgets and text widgets. (Are there any non-form widgets? I can't find form PDF32000 spec)
I can do rebase, refactor code, unit tests, rename preference without too much problem, but I agree we need a good structure first. |
@xlc I agree with you that we need to think more about how to structure this properly. Fixing up this PR should not be too hard, but it's the structure that is really important in order to extend this also to all other annotation types. |
@@ -634,7 +635,7 @@ var LinkAnnotation = (function LinkAnnotationClosure() { | |||
if (!isValidUrl(url, false)) { | |||
url = ''; | |||
} | |||
// According to ISO 32000-1:2008, section 12.6.4.7, | |||
// According to ISO 32000-1:2008, section 12.6.4.7, |
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.
This change is no longer necessary when you rebase the patch as it has been fixed already in another commit.
This PR needs a rebase now that your other PR landed. |
if (!isMultiline && !('fontSize' in this.data)) { | ||
// hack to guess font size base on content hight | ||
// so it display fine on small text field | ||
// this need to be removed when we can apply defaultAppearance |
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.
Change this to // TODO: remove this when we can apply the default appearance.
dc20ff9
to
78cf950
Compare
@timvandermeij Updated. |
this.container.appendChild(content); | ||
return this.container; | ||
if (!isMultiline && !('fontSize' in this.data)) { | ||
// hack to guess font size based on content hight |
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.
Nit: start with a capital H and change "hight" to "height"
This is looking much better than before. Could you address the other nit above and then squash the commits into one? |
Also, unless I'm overlooking something, isn't #6172 (comment) still unaddressed? |
Good point, that one has to be addressed too. |
54e9f5d
to
b6c9c04
Compare
What will be the best way to save the values? Should I create a FormFieldStorage class to store the values? Or add a field to other existing class? |
include = false; | ||
} | ||
} | ||
if (include) { |
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.
@Snuffleupagus @timvandermeij I have implemented a storage solution, what do you think? |
@timvandermeij Can you have a look? |
@xlc The branch needs to be rebased. Care to do that and ping @Snuffleupagus again afterwards? |
Closing as superseded by a series of merged PRs that implemented this functionality. The remaining tasks (printing, storage and appearances) are tracked in #7613. |
There is already an example implementation of AcroForms in the examples folder. This PR aim to do it properly.
This PR only provide basic implementation of text input fields. Other types of fields (buttons, choice) will be implemented in later PRs.
Issues & Questions:
$('.annotationLayer .widgetControl').on('change', changeHandler);
PDFPageView
to read/write/listen values.