This is a migrated thread and some comments may be shown as answers.

Form Field Rename

3 Answers 97 Views
PdfProcessing
This is a migrated thread and some comments may be shown as answers.
Kurt
Top achievements
Rank 1
Kurt asked on 09 May 2018, 06:55 PM

Hi,

  Have a batch PDF template job and part of its requirement is to update legacy templates.

  Anyone know of a way to rename an existing form field in a PDF file?

 

Thanks,

- K

3 Answers, 1 is accepted

Sort by
0
Polya
Telerik team
answered on 14 May 2018, 08:42 AM
Hi Kurt,

We have a great example demonstrating how to modify the form field values of a PDF document and save the result. You can find it in our developer focused examples: https://github.com/telerik/document-processing-sdk/tree/master/PdfProcessing/ModifyForms//.
Hope this helps.

Regards,
Polya
Progress Telerik

0
Kurt
Top achievements
Rank 1
answered on 14 May 2018, 05:02 PM

Hi Polya,

  I don't see anything in that example relating to "renaming an existing form field".

  Did you mean to paste a different reference link?

 

- Kurt

0
Polya
Telerik team
answered on 16 May 2018, 03:01 PM
Hello Kurt,

I assumed that by "rename an existing form field" you meant changing the value of the field. If that is not the case, please excuse my misunderstanding.

If you wish to change the Name property of a FormField, currently there is no out-of-the box way to achieve that. You can find a feature request for this logged in our Feedback Portal: https://feedback.telerik.com/Project/184/Feedback/Details/249535-pdfprocessing-provide-a-way-to-rename-formfields where you can track its status and vote for it.
As a way to achieve the desired, you could create a new instance of a FormField with the desired name, add the new field in the document and remove the old one. You can use the following approach:
  1) Create a new instance of FormField (with the desired name, passed in the constructor), which will play the role of a copy of a specific FormField
  2) Copy all properties from the original field (they all vary, depending on the concrete type of the FormField, for example CheckBoxField, etc.)
  3) Create a new widget for the new field, and copy all properties from the original field's widget into the new one.
  4) Remove the original field from the RadDocument.AcroForm.FormFields collection and add the new field.
  5) Remove the original widget from the corresponding page's annotation and add the new one.

I've prepared a sample project demonstrating this approach. Please find it attached.
If this is what you wish to achieve, I hope this approach helps. If, however, it is not, I will kindly ask you to provide more information on your scenario and what do you mean by renaming an existing form field.

Regards,
Polya
Progress Telerik

Tags
PdfProcessing
Asked by
Kurt
Top achievements
Rank 1
Answers by
Polya
Telerik team
Kurt
Top achievements
Rank 1
Share this question
or