FAQ

How to break up text into single characters for populating a PDF

September 2, 2021

You can break up text into individual characters in order to populate PDFs that require it, for example how this PDF requires that you populate a social security number:

How it works

You must create a variable for each individual character of the text you wish to break up. Continuing with the example of a social security number (SSN), this means you will have to create 9 variables, one for each character of the SSN. Here is how this works:

First, let's assume you have a variable called `user_ssn` defined by a short text question, like this:

Next, use an expression block to create a variable that will equal the first character of `user_ssn`. To do that, start the expression with `user_ssn`, use the operator "character at", and then type in the number "1". We can call this new variable `user_ssn_character_1`:

Repeat this process ^ for the remaining 8 characters in `user_ssn`.

Once you have a variable for each individual character, draw text field on your PDF template for each character: 

Finally, assign each character to the new text fields you've draw on your PDF template.

🎉 That's it!

Admittedly, this is a tedious process. Ideally, PDFs would not have such unforgiving formatting requirements. But if you can't change the PDF formatting (we're looking at you, government forms), this approach at least allows you to continue with your automation project.

Hire an Afterpattern expert

Go from idea to launch in weeks.

View services