Is it possible to capture checkbox selection(cross

2019-09-20 04:15发布

问题:

I had an editable pdf with checkbox, after selection i flatten that pdf. from that flatten pdf i need to read the checkbox selection which is looks like crossmark(X), is there any possibility to read that checkbox selection.

回答1:

When you flatten a PDF, you take away all interactivity. If you have a check box field in an interactive form, and you flatten that form, the check box field is gone. That is the concept of flattening.

What happens in practice?

A check box field has two appearances. One appearance is Off. This appearance can be a path such as a simple square defined as a rectangle. Another appearance can have any name On, Yes, 1 or whatever is defined in the original form. The corresponding appearance can be the same square as the Off appearance with two extra lines that look like a cross, or the square with a character that looks like a check mark, or whatever was defined in the original form.

When you flatten the form, you throw away the name of the check box field, you throw away the widget annotation that corresponds with the field, and you throw away one appearance state (depending on the value of the check box field). The only thing that is left, is one of the two appearances.

If you no longer have the original form, you have no clue as to what this appearance could look like, hence you have no idea what to look for, nor where to look for a specific appearance.

You say that the appearance looks like a cross mark in your case, but whoever reads this question has no idea if this cross mark is a path that was constructed in graphics state, or a glyph that was added in text state.

Long story short: if you flatten first and then expect to be able to read a field value, your design is seriously flawed.

You have to ask yourself: why do I need to flatten the form? Maybe it's sufficient to make the fields read-only. If that's not sufficient, why don't you add an attachment to the PDF that contains the original field values? There are many different ways to work around your problem.



标签: itext