문제 설명
JAVA에서 PDF 양식 테이블 채우기 (Filling PDF form tables in JAVA)
내가 원하는 양식 유형이 있습니다. 목록을 작성하십시오. 모든 Acro 필드를 가져오려고 시도했지만 셀과 관련이 없으며 목록을 반복하여 관련 값을 채우기 위해 해당 셀을 식별해야 합니다. 예를 들어 첫 번째 표에는 세그먼트 A에 대한 목록이 있습니다. Itext를 사용하여 미리 생성된 양식을 채우는 방법을 알려주십시오.
참조 솔루션
방법 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:
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:
- How to fill out a pdf file programatically?
- Checking off pdf checkbox with itextsharp
- Change AcroFields order in existing PDF with iText?
- ...
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.
(by Jain‑user3000947、Bruno Lowagie)