Free Support Forum - aspose.com

Text not selectable after setting with FillField

Hi,

I have pdf template with some static text and some text fields. The fields i set with FillField.
As result, i want a pdf without any interactive fields, so i set the fields to readonly with SetFieldAttribute. Have a look at the code:

            Form form = new Form(@“c:\temp\test.pdf”, @“c:\temp\testnew.pdf”);
        form.FillField(<span style="color:#a31515;">"text1"</span>, <span style="color:#a31515;">"my text 1"</span>);
        form.SetFieldAttribute(<span style="color:#a31515;">"text1"</span>, <span style="color:#2b91af;">FieldFlag</span>.READ_ONLY);

        form.FillField(<span style="color:#a31515;">"text2"</span>, <span style="color:#a31515;">"my text 2"</span>);
        form.SetFieldAttribute(<span style="color:#a31515;">"text2"</span>, <span style="color:#2b91af;">FieldFlag</span>.READ_ONLY);

        form.FillField(<span style="color:#a31515;">"text3"</span>, <span style="color:#a31515;">"my text 3"</span>);
        form.SetFieldAttribute(<span style="color:#a31515;">"text3"</span>, <span style="color:#2b91af;">FieldFlag</span>.READ_ONLY);

        form.FillField(<span style="color:#a31515;">"text4"</span>, <span style="color:#a31515;">"my text 4"</span>);
        form.SetFieldAttribute(<span style="color:#a31515;">"text4"</span>, <span style="color:#2b91af;">FieldFlag</span>.READ_ONLY);

        form.Save();</pre>

The problem now is that i cannot select the text of those fields anymore in the produced pdf. I’ve attached the template(test.pdf) and the resulting pdf(testnew.pdf).

Is there a way to use FillField and as a result to get a plain pdf file without interactive fields where i can select all text within a reader?

cheers
manuel


Problem solved with FlattenAllFields(). With this approach, it is not needed to set the field attribute to readonly…

cheers

Hi Manuel,

I’m glad to know that the issue is resolved at your end. If you find any further questions, please do let us know.

Regards,