Hi all

I am quite new to PDF generation, therefore may not have all of my
terminology completely straight, please feel free to correct me.

What I have at present (and working just fine), is a template PDF form,
using the PdfStamper to fill the values of static fields, then flatten the
form, and this is all working fine.

Now where I have hit a slight snag, is populating form fields that are
intended to be repeating. Please excuse me if I have left something out
here, but I have spent quite some time researching this, and failing to find
helpful documentation on Adobe's site, in their application, or on the
Internet about this scenario, I have decided to consult the mailing list.

I'm not 100% sure on what is and is not possible with databinding and PDF
forms (for the classic dynamic "Purchase Order" scenario, with variable
numbers of line items).

Now I understand iText has some support for XFA (at least, navigating around
in the Xfa member of the AcroFields property of PdfStamper, I can see there
is XML in there that resembles to a large extent what I get when I'm looking
at the "XML Source" view in Adobe LiveCycle Designer).

MergeXfaData() seemed to be what I'm after, but I have a hard time
understanding what the required input XML for this function should be, or
whether it even refers to form data, or whether it is just another way to
override the XFA associated with the document.

Some interesting snippets when I looked at the "XML source" for this
document (before it was written out to PDF), it seems to be describing to
some extent the "schema" of allowable data to bind against the dynamic field
over here (which I thought could be the input to MergeXfaData()):

  <xfa:datasets xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/";>
  <xfa:data xfa:dataNode="dataGroup"/>
  <dd:dataDescription xmlns:dd=" http://ns.adobe.com/data-description/";
dd:name="LineItems">
     <LineItems>
        <LineItem dd:maxOccur="-1">
           <Quantity/>
        </LineItem>
     </LineItems>
  </dd:dataDescription>
  </xfa:datasets>

Then, we also see a <field> definition, which looks like what I can access
in iText when I look at the DOM nodes in DatasetsSom/TemplatesSom:

           <field name="ItemQuantity" y="6.35mm" w="19.05mm" h="9.525mm">
              <ui>
                 <textEdit>
                    <border>
                       <edge presence="hidden"/>
                       <edge presence="hidden"/>
                       <edge/>
                       <edge presence="hidden"/>
                       <?templateDesigner StyleID aped1?></border>
                    <margin/>
                 </textEdit>
              </ui>
              <font typeface="Arial"/>
              <margin topInset="1mm" bottomInset="1mm" leftInset="1mm"
rightInset="1mm"/>
              <para vAlign="middle"/>
              <caption reserve="0in">
                 <font typeface="Arial"/>
                 <para vAlign="middle"/>
              </caption>
              <bind match="dataRef" ref="$record.LineItem[*].Quantity"/>

Is there some way (in iText) that I can indicate I have some XML to "merge"
into the template, with iText consulting the <bind> member to determine
which component of incoming XML contains the data to bind, and then
assigning it to the form fields as necessary (creating new fields if so
required), or does iText not support this scenario of data binding yet?

I tried inventing new "indices" for field names when doing a SetField(), e.g
.

LineItems[0].PurchaseOrderData[0].LineItems[0].ItemQuantity[1]

But that obviously had no effect, and I'm not sure that it would do
anything.

I hope I'm making sense here, and thanks in advance for any clarification on
whether what I want to achieve is possible at this stage.

(1) I am using iTextSharp, but as it has parity with (and is based on)
iText, I thought it was applicable to post here.
(2) I know that Adobe has something called XPAAJ which is supposed to
support this scenario, but I would prefer to use iText if possible. Worst
case, I may have to resort to writing a web service using XPAAJ that does
what I need, but I'd prefer to avoid that if possible :)

Thanks!
Leon
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/

Reply via email to