-3

I have this type of form which I want to fill form a list. I have tried getting all the Acro fields but those are not relevant to the cells and I need to identify their cells to fill relevant values by iterating over a list. For Example in first table I have a list for Segment A . Please tell me how to fill precreated form using Itext .

  • 2
    You might want to upload the contents of your link to somewhere publicly accessible like pastebin or imgur. I don't really want to get your permission to look at the linked document. – Mike Dec 06 '15 at 04:50
  • Hi Mike, this document is just for sample . in which I want to fill the data using iText JAVA API . @Mike – Jain-user3000947 Dec 06 '15 at 11:55
  • *Dag Jain, welkom op StackOverflow! Heb je de FAQ gelezen vooraleer een vraag te posten?* I guess that you are getting down-votes because you have shown very little effort trying to answer your question yourself. There is an abundance of documentation available online: see for instance [questions and answers about forms](http://developers.itextpdf.com/faq/category/interactive-forms), [Chapter 6 of my book](https://manning-content.s3.amazonaws.com/download/3/3c9ca46-76da-4de2-8972-b82efbe0bf88/samplechapter6.pdf),... What didn't you understand after reading the documentation? – Bruno Lowagie Dec 06 '15 at 12:17
  • Hi Bruno , I have gone through you all links but the main problem is a bit different which I have mentioned in my reply to your answer below. Kindly help me in this way . I'd be grateful to you Sir. – Jain-user3000947 Dec 06 '15 at 13:27

1 Answers1

1

Allow me to split up this very broad question into two different questions.

1. You have an interactive form. How can you retrieve the field names / types?

This is explained in different places.

It's explained in Chapter 6 of "iText in Action - Second Edition". See p181-183 under the title "Inspecting the form and its fields" where you'll find a reference to the FormInformation example.

It's explained in the online documentation tagged with the words Inspect fields, for instance in the answer to the question How to get specific types from AcroFields? Like PushButtonField, RadioCheckField, etc, which was actually an answer to a question on StackOverflow: iTextSharp. How to get specific types from AcroFields? Like PushButtonField, RadioCheckField, etc (I removed that answer because the person who asked the question was extremely rude in his comments.)

If you want to know which fields are defined in a form without writing code, you can use iText RUPS. In the screen shot below, I have opened your PDF in RUPS:

enter image description here

I see fields such as "Klantnaam" (name of the customer), "Aantal1" (amount 1), "Segment1" (segment 1), "Leaseprijs1" (lease price 1),... (Hé, ben jij ook Nederlandstalig?)

2. How do you fill out a form, once you have the names of the fields?

That's also explained in Chapter 6 of "iText in Action - Second Edition". See p183-186 under the title "Filling out the form" where you'll find a reference to the FillDataSheet example.

You can find other examples online under the Q&A section about interactive forms, the example section about forms, or under the content tagged "Fill form". See for instance the answer to the question How to fill out a pdf file programmatically? (AcroForm technology).

Request for feedback:

We take great pride in the fact that we provide high-quality documentation. Most of the Q&As on the site are answers provided by us on questions previously posted on StackOverflow, but we rearranged, edited and categorized them for your convenience. See for instance:

We regret that the information provided by us wasn't sufficient for you, and we hope that you will give us feedback so that we can further improve our documentation.

Community
  • 1
  • 1
Bruno Lowagie
  • 75,994
  • 9
  • 109
  • 165
  • thanks for your valuable reply . I have gone through all the links and still the problem lies in identifying the right keys . Because in table each cell has different keys . If I have a list which should be filled columnwise or row wise but the problem lies in identifying exact key for each cell. Coz keys extracted from acrofields are not in sequence. .. I tried to fill but it filled the list values in irregular cell order. – Jain-user3000947 Dec 06 '15 at 13:25
  • No I am not dutch .. I have used iText RUPS tool to identify form keys but the main problem is that these keys are not in sequence so that I can fill the whole column by column from my List object. Is there any way to do that or I can change the order of the cell's keys. – Jain-user3000947 Dec 06 '15 at 15:20
  • You should do a better effort to explain your problem. Why is it important that "the keys are in sequence"? Every key corresponds with specific coordinates on the page. That order is correct. Changing the order of the cell's keys is unnecessary. Why would you care in which order they are presented? In its current state, your question doesn't make any sense. – Bruno Lowagie Dec 06 '15 at 15:24
  • Or are you still criticizing the online documentation? Are you saying that you didn't find the answer to the question [How to find the absolute position and dimension of a field?](http://developers.itextpdf.com/question/how-find-absolute-position-and-dimension-field) – Bruno Lowagie Dec 06 '15 at 15:27
  • I am not criticizing the document Sir . – Jain-user3000947 Dec 06 '15 at 15:58
  • I am just trying to figure out a way to find all the keys .. So that I do not need to find and order all the keys column wise manually . – Jain-user3000947 Dec 06 '15 at 16:00
  • Finding all the keys: that's documented. Order all the keys: how? alphabetically? Use a sort function. By location? How do you want them ordered? Right-to-left, bottom-to-top? Bottom-to-top, left-to-right? In that case, use the [position of the field rectangles](http://developers.itextpdf.com/question/how-find-absolute-position-and-dimension-field) to order them. By tab order? That info isn't always available, but that's possible to. Please show some effort! What have you tried so far? – Bruno Lowagie Dec 06 '15 at 16:04
  • I have tried it .. but the keys like Aantal01 , Leaseprijs01...10.. or segment01 .. ans so on .. are not in order according to cells which I need to find out . For example If I take first column then I should have all the keys in sequence to fill out their values from my List object . Identifying which key belongs to which cell is taking lot of time for several similar pages. – Jain-user3000947 Dec 07 '15 at 03:25
  • If a column or row cell starts with any key sequence then it should be in order but its like jumbled or shuffled so I need to indentify exact key per cell . – Jain-user3000947 Dec 07 '15 at 03:29
  • Did you take a look at the position of each field? I can only repeat: did you try the answer to [How to find the absolute position and dimension of a field?](http://developers.itextpdf.com/question/how-find-absolute-position-and-dimension-field) Was there something you didn't understand, for instance: [How should I interpret the coordinates of a rectangle in PDF?](http://developers.itextpdf.com/question/how-should-i-interpret-coordinates-rectangle-pdf) Why are you still messing around with the names of the fields when you say you want to know the positions??? – Bruno Lowagie Dec 07 '15 at 11:34
  • I did it my way.. Thanks. – Jain-user3000947 Dec 09 '15 at 07:04