These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Is it just me or is this a Massive PDF limitation?

cschilke
Registered: Feb 5 2009
Posts: 6
Answered

It is my understadning that I can create an AcroForm with variables. I use the iText Jar to assist me in reading a "template" PDF with these variables. I load these variables at run time and produce many PDF's from this. For instance, I have to generate letters that say:

"Thank You Mr. John Doe"

This works fine because my Java program can access a variabe called "UserName" and load it with "Mr. John Doe" at runtime. Cool! This is the flexibility I need and now I need to implement it elsewhere in the PDF...

-- However -- :(

Adobe hasn't come up with a solution (or they don't care) for the following (or am I crazy)?

"Thank You Mr. John Doe for your recent donation."

In fact, if my client wants a freaking period (.) after "Thank You Mr. John Doe" I can't give it to them unless I bury the period in my variable (major hack)!

The first example works (but it's a hack) because I can add a Text Box after "Thank You ". lining up this Text Box is a nightmare but eventually it will work. But, putting a Text Box in the second example just stamps the box over the existing text. In other words, it doesn't adjust itself to fit within the text.

I called Adobe and the customer service rep said Adobe has no solution for me. Now, what makes this worse is Adobe knows there's a need for this. Why you ask? Well, using Adobe' Life Cycle UI you can create a "Floating Field", which is 'almost' awesome. In the UI I can do this:

"Thank You {UserName} for your recent donation."

-- However -- :(

This is just a LifeCycle UI "thingy" that loads these values prior to generating/creating the PDF. In other words, LifeCycle tries to overcome this MASSIVE PDF deficiency but this means you can't use this functionality outside of LifeCycle (i.e., no possible way to use Java and iText to automate this).

I understand that a PDF text isn't constructed at runtime but I blame Adobe for poor architecture with this limitation. Think about it, a user says, "Can you imbed John Doe's first name in the PDF text somewhere" and I, the 'wonderful' programmer has to say, "No, that's too difficult"....Incredible.

This limitation is amazing is it not?

Trust me, I'm really not this cynical -- I'm just really disturbed with this limitation. :(

Please educate me if I am wrong.

Cheers!

George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
It's seems you've decided to implement this using form fields, but that's clearly not the best approach in this case. Have you looked at other approaches you can take using iText? They have an active mailing list where folks can probably give you more guidance.

George
cschilke
Registered: Feb 5 2009
Posts: 6
I'll look into your suggestion. Thanks for your reply. It's frustrating when you get so close to a full solution but the software which is beyond your control can't get you that last 1%.
cschilke
Registered: Feb 5 2009
Posts: 6
No can do. It's now apparent that Adobe doesn't offer a solution. I have to tell my client that my proposed solution will not work because an Adobe PDF AcroForm can handle the first line but not the second line (see below):

"Thank You Mr. John Doe"
"Thank You Mr. John Doe for your recent donation"

After telling my client about this they just stared at me...then they started laughing at how stupid this limitation is.
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
FWIW, a form field can do the simple thing you described. What's not clear to me is how the rest of the document needs to be layed out. If you could post a sample document somewhere, it would be helpful.

Are you saying that you've investigated some alternative methods of adding text to a document using iText and found them lacking in some way?

George
nixopax
Registered: Feb 6 2009
Posts: 105
I have recently run into this sort of things as well, and find it funny at times, the limitations that Acrobat has. A sad sort of funny though. What I think you could do in this situation, and it would be too bad if you had to go about it this way, but you could have any dynamic text set as a text field could you not? Make the text form field readonly. Then, once the user has set the "first_name" variable, will_Commit sets all the variables in the document using regular expressions. {first_name}, or something along those lines. Then, providing the name isn't too long, the format of the text shouldn't be thrown off by much, provided the text form field is set to multiline with enough extra whitespace for room to move.

var first_name = this.getField("first_name");
var Pg1_Body_text = this.getField("pg1_body_text");
var Pg2_Body_text = this.getField("pg2_body_text");
//etc...

//The following function would be called upon event.willCommit in the first_name text field keystroke is true.
function replacefield()
{
Pg1_Body_text.replace(/\{first_name\}/, first_name);
Pg2_Body_text.replace(/\{first_name\}/, first_name);
//etc...
}

Now, if there are any Regex masters here, they could probably sort you out with a much more streamlined process.