>> I understand. I'll give you two pointers that are secreted
>> away on the net (Google is good, but doesn't always find what
>> you're looking for). I hope they can help you:
>> 
>> There's an article about the Belgian eID here:
>> http://itext.ugent.be/articles/eid-pdf/index.php#template
>> The section "Using an AcroForm as a template" first describes more
>> or less what you are doing (but it dates from before PdfSmartCopy
>> existed), then there's an extra example "for the sake of completeness"
>> that IMO is more important than the first example:
>> http://itext.ugent.be/articles/eid-pdf/test/BatchFormFill.java
>> You'll recognize stuff you've found in the book, but it's a more
>> "bare bones" example, easier to understand without any XML involved.
>> 
>> The second pointer can be found in the mailing list archives.
>> I usually find more info by searching the archives for "Gatewood"
>> (the developer who originally posted a similar question) because
>> looking for "AcroForm" and "template" returns too many other hits
>> (that's what I meant with "secreted away" earlier).
>> This mail contains an interesting code snippet:
>> http://www.nabble.com/Re%3A-BINGO%21-creating-new-document-where...
>> This second pointer isn't exactly what you are looking for, but
>> it could give you some inspiration.
>> -- 
>> This answer is provided by 1T3XT BVBA

This was good information.  I adapted the first example to my own program,
and it is close to working, and OH it is SO much faster and smaller and less
memory-intensive than the other way.  

There is still a small problem or two I'd like help on.

I created my own PdfFormFiller class; its constructor reads and saves each
field's name, positions, and type, and then a 'filler' method is called once
per set of data to put all the field values into the output.  

The PdfContentByte var for output is passed in, and called 'contentByte' in
the following.  Here is the central part of the filler method code; it is
within a loop that iterates once per form on the field:

--

      if (null != value && null != formField)
      //try
      {
        contentByte.beginText();
        contentByte.setFontAndSize(baseFont, 9);
        contentByte.showTextAligned(Element.ALIGN_LEFT, value, 
                                                        formField.box.left(), 
formField.box.bottom(), 0);
        contentByte.endText();
        
        //ColumnText columnText = new ColumnText(contentByte);
//writer.getDirectContent());
        
        //columnText.setSimpleColumn(new Phrase(value),
        //                                         formField.box.left(), 
formField.box.bottom(),
        //                                         formField.box.right(), 
formField.box.top(),
        //                                         16, Element.ALIGN_LEFT
        //                                        );
        //columnText.go();
      }
      //catch (DocumentException xcp) { xcp.printStackTrace(); }

--

'box' is a field within an inner class FormField; box is of type
com.lowagie.text.Rectangle, and (obviously) set to the boundaries of the
field before this code is executed.

As shown, this fills in fields pretty well; however, I have a few fields on
the document that are multi-line.  For those, it puts one line of text at
the bottom of the multiline field.

I figured I needed the other part of the example, using ColumnText, so I put
in the commented-out lines you see above.  If I remove those comment
delimiters, and comment out the beginText/endText sequence, the code fills
in ONLY multi-line fields -- nothing appears in the rest of my fields, which
are all shorter than one line.  The text in the multi-line fields also
appears in a larger font than I'm going to want to use.

I tried putting back in the contentByte.setFontAndSize() call by itself for
the use of ColumnText, but that made no difference in either size or
content.  I don't know whether I need that wrapped in beginText() /
endText().

So my questions are:

1) how can I show all my fields, preferably doing both multiline and
part-of-line fields the same way so they will wrap when necesssary without
my having to keep track of which field is multiline and which isn't.

2) Assuming I can use ColumnText for that, how can I set font and size for
ColumnText fields; the methods as shown in the online javadoc didn't have a
way to do that that I saw.

(p.s. a brief aside: the download link for downloading the iText javadoc
gave me a 404 error this afternoon, in case someone's reading who can fix
that.)

Thanks for the tip (two-pronged tip?) I got from 1T3XT; it really did help. 
After I'm finished with what I'm doing, I intend to post it back here for
others to see.  I think this stuff can be explained better, or at least
more.  Incidentally, my code and methods do not use the "listener"
interface, which I think can confuse people as to what needs to get done
when.  So stay tuned.

rc
-- 
View this message in context: 
http://www.nabble.com/one-Acroform%2C-multiple-sets-of-data-tp16315795p16339517.html
Sent from the iText - General mailing list archive at Nabble.com.


-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
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/

Reply via email to