Hi,
I've written loads of code to produce PDF of about 4 pages.
This PDF is generated from a datamodel.
But now I've run into the situation where it is possible that not all
data is available in the data model, and for the things missing I
would like to create TextField so it could be filled in afterwards.
Document pdf = new Document();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
PdfWriter writer = PdfWriter.getInstance(pdf, baos);
...
pdf.setFooter(hf);
pdf.open();
PdfPTable table = new PdfPTable(2);
...
and then I have loads of lines like:
table.addCell(model.getProperty("someProperty"));
What I want to do now is to check if the property exists by doing:
if(model.getProperty("someProperty")!=null){
table.addCell(model.getProperty("someProperty"));
}else
{
//Create TextField here and add it to the table.
}
I've tried to insert code like it is mentioned in the book in chapter 15:
TextField tf1 =
new TextField(writer, new Rectangle(40, 720, 360, 750), "fox");
tf1.setBackgroundColor(Color.YELLOW);
tf1.setBorderColor(Color.RED);
tf1.setBorderWidth(2);
tf1.setBorderStyle(PdfBorderDictionary.STYLE_BEVELED);
tf1.setText("Quick brown fox jumps over the lazy dog");
tf1.setAlignment(Element.ALIGN_CENTER);
tf1.setOptions(TextField.REQUIRED);
writer.addAnnotation(tf1.getTextField());
But this doesn't work at all, I don't find a trace ot this text field
in the resulting PDF.
By the way, there is no other place I reference the writer object
directly. Maybe this is what's causing the problem??
Oh and I should be able to fill in this resulting form by using a
program like acrobat or code wise (to update the PDF when the data
becomes available at a later time)
Can somebody please help me with this or suggest a different approach??
Thanks alot!
Greetings,
Kristof Taveirne.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/