0

How do I add blank spaces inbetween character? I'm using a PDF/AcroField;

enter image description here

See the routing field, I'd like to make "12345" into "1 2 3 4 5".

Javascript is allowed to validate forms, so maybe I can use that?

Abraham
  • 1,209
  • 2
  • 14
  • 22

1 Answers1

1

There are many ways to add blank spaces in between characters.

var string = "12345";
string.split('').join(' '); // String.split + Array.join
string.replace(/(.)/g, "$1 ").trim(); // Regex

You could also use a for-loop. etc.

As for your follow-up question about how to read AcroField values, based on this Stack Overflow post I'd suggest trying something like this:

PdfReader reader = new PdfReader( pdfPath );
AcroFields fields = reader.getAcroFields();
Set<String> fldNames = fields.getFields().keySet();

for (String fldName : fldNames) {
  System.out.println( fldName + ": " + fields.getField( fldName ) );
}
Community
  • 1
  • 1
bvaughn
  • 13,300
  • 45
  • 46
  • How to I set the string to be equal to the value of the AcroField? – Abraham Mar 31 '15 at 04:03
  • You asked how to add blank spaces in between characters in a string, so that's what I gave an example of. ;) I've never used AcroField before but based on what I see online..I'll update my example. – bvaughn Mar 31 '15 at 04:18