how to fill dynamic content of dynamic XFA form (itext 7)? - java

I'm using itext 7 to fill dynamic xfa form. I tried example provided in itext website which work for static part of PDF but dynamic part so not displaying on render filled PDF.
The PDF have an add button, on clicking add button few fields appears. This fields are not displaying even when values for this fields are filled. Can anyone suggest any approach to solve this problem.

Related

Is there a way to set page orientation to landscape when a specific element is found in OpenHtmlToPDF (or another HTML to PDF converter)?

The functionality for the project that I am currently working is to get data from a WYSIWYG editor and convert all the input to a PDF document. The problem is sometimes there is necessary to add wider tables and this produces a truncated visualization of them.
To solve this problem, I added to the editor (specifically, CKEditor) a HR button but I renamed it to "Change page orientation", so users can click that before inserting a table. In Java, I used iText 7 to detect this element (<hr>) and change the page orientation. This works like a charm.
Example using iText with a simple table
Now, requirements changed and for license purposes we need to replace iText for another HTML to PDF converter, but we need to keep this functionality.
I found OpenHTMLToPdf and I liked it, but I didn't find the way to replicate this page orientation when a hr (or another specific element) is found.
How can I solve that? I can use whatever library as long as they are open source.

iText and AcroFields styling fonts doubles the fields text

i'm facing a problem usintg iText together with java in order to populate form fields.
i've created the form field in a PDF Document using Acrobat 11 Pro and i've been able to populate it with all the values i needed using iText and AcroFields.
Troubles startet to raise when i modified fonts style, size and alignment using Acrobat 11. Now, for each input i modified the style, when i'm using the setField method i get twice the content one that has the aspect i've set in Acrobat 11 and the other that has the default style
Has anyone already tackled that issue?

Programmatically click a button on a PDF XFA form using itext

I have a PDF xfa form that I am filling out with iText. I am unable to fill certain fields as they become enabled in the form only after clicking on a certain button within the form. This button actually calls a webservice that returns data. The data is used to fill up other fields which I am not bothered with. But only after clicking this button the fields that I am trying to fill out with XML data become enabled (non read only). I can't change the form.
So I am guessing the only way I can fill out these fields by merging the XML data is by clicking this button. Is there a way I can click this button using Itext and then merge the pdf with the xml data I am sending it?

Use iText to produce formatted TextFields?

Is there any way in iText to format a TextField's input? I want to have a TextField accept a phone number "(###)###-####", but I don't want the user to have to format it when they enter it. Pdf supports masks on form fields, is there any way to do this in iText?
My current solution is to create the pdf in Acrobat, then populate known fields through iText. But that isn't ideal for this deployment. Ideally I'll have iText generate the entire form.
Thanks for all assistance in advance.
You can add JavaScript to your form that changes the content of fields. See for instance the Calculator example for a fun PDF that acts as a Calculator (obviously this app only works in a PDF viewer that supports JavaScript).
When you create a text field, you need to add an additional action with the setAdditionalActions() method. You can choose between different events: K for keystroke (e.g. useful if you want to change every character to uppercase when somebody fills out a form), Bl for blurred (useful to process the content of a field as soon as the focus is lost), etc.
You can write your own document-level JavaScript to format the fields. See calculator.js for the JavaScript used in the Calculator example. Or you can use one of the many AF methods that are predefined Adobe Reader, such as AFNumber_Format (I don't find an overview of the available methods right now).

Editing a PDF file with Java

I'm trying to edit a existing PDF file. It is a file where I need to fill in some addresses and other stuff. I want to connect an addressbook to the application so the user can select a user from the addressbook and a part get filled in automatic.
My questions are:
Is it possible to edit a existing PDF file and fill in some fields (+/- 20), because I know there is Itext (http://www.itextpdf.com) but I read that the possiblities are very small.
Or can I better convert the PDF to JPG and get it as background. And create JLabels on the places where I need to fill in the fields. And then print the whole Frame on a A4.
Or are there better posibilities?
So what I need to do, step by step:
Select one of the PDF's (they are in the program)
Fill some fields with content/addresses
Print the PDF/Form with a printer
There is a toolkit given by Adobe named as Acrobat Forms Data Format (FDF) Toolkit which gives API for different languages to fill forms.
You can get the java code at the bottom of that page or check this link
We didn't edit existing PDF's but created totally new letters/reports/doco from our java app using iReport
You could use pdf form and edit field values programmatically using IText or Apache PDFBox (download pdfbox and see SetField.java example)

Categories