newBrain
newBrain

Reputation: 103

how to find and replace a text into a pdf file using iText in

I have a pdf form, the structure is following

      Hello firstname,

      Mr. firstname you are currently working at the designation post 
      and your current package is salary.

      Thanks.

       Excel database
       --------------------------------------
      + firstname + salary   + designation  +  
      |-----------|----------|--------------|
      | Alin      | 3,00,000 | Manager      |
      | Roy       | 2,75,000 | Php Developer|
      +-----------+----------+--------------+

Here the keyword firstname,designation and salary is fetched from the excel database and change dynamically. suppose if user select alin then in pdf form in firstname is replace by Alin and salary and designation is replace by 3,00,000 and Manager respectively.

My problem is that i am new in iText i can't find the way how to search and replace these keywords. Any help is appreciated.

Upvotes: 0

Views: 2163

Answers (1)

duffymo
duffymo

Reputation: 308763

I wouldn't consider iText as my preferred technology to do this.

I'd use a Velocity template for XSL-FO, populate it with dynamic data, generate XSL-FO, and turn that into a PDF using standard XSL-T engine. Convoluted, but effective.

Or, if you wish to stick to the iText track, just figure out how to do the substitution in Java objects and generate the form that way.

I wouldn't recommend Excel as a "database".

Upvotes: 2

Related Questions