Skip to main content
Participant
January 12, 2017
Answered

Remove accents from entire PDF form on submit

  • January 12, 2017
  • 2 replies
  • 2706 views

Hello!

Any ideeas how to remove all accents from all PDF form inputs on submit?

I am interested in doing this on client side, before the submitted data reaches the server.

I.e. i type in a input field from the PDF form the string "șțâȘȚÂ"  and after submit button is pressed the output needs to be "staSTA". I did some research on some topics with javascript but it didnt work out for me.

Thanks!

This topic has been closed for replies.
Correct answer try67

The doc-level script would be something like this:

function replaceAccents(s) {

    s = s.replace(/ș/g , "s");

    return s;

}

And then you call it like this:

this.getField("Text1").value = replaceAccents(this.getField("Text1").value);

2 replies

JR Boulay
Community Expert
Community Expert
January 13, 2017

Hi.

Can't the JavaScript-GREP use Posix regex ?

In a regex, searching for [[=a=]] mean searching any form of the "a", with or without accent, then you can replace by a "a".

This works for any letter.

Acrobate du PDF, InDesigner et Photoshopographe
try67
Community Expert
Community Expert
January 13, 2017

No, it can't, but you can match multiple character by putting them in

square brackets.

try67
Community Expert
Community Expert
January 12, 2017

Yes, this would require using a custom-made script. You would need to write a function that replaces the accented characters with non-accented ones and then call it for each (text) field in your file, before submitting it.

CilonSAuthor
Participant
January 13, 2017

Problem is i don't know how to work with adobe pro so well...i only found out how to add a custon keystroke script in the text field properties of the adobe form. Did something like this:

if (!event.willCommit) {

    event.change = event.change.replace(/ș/g , "s");;

}

But this replaces my char as i type, and i want it to be changed when i press the submit button.

CilonSAuthor
Participant
January 25, 2017

Thank you very much! It works!!!


I'm trying to loop trough all fields in the document like this:

    

for (var i = 0; i < this.numFields; i++)

         {

               var fieldName = this.getNthFieldName(i);

               this.getField(fieldName).value = replaceAccents(this.getField(fieldName).value);

          }

but it does not work...any ideeas why?