5 Replies Latest reply on Jan 27, 2007 11:32 AM by Norman Richards

    pdf form 'filling and generic overlay proposition

    Ronald van Kuijk Master

      I've been looking a little into implementing generic text and image overlay for an existing PDF and output that as a new pdf.

      Besides needing a PdfStamper instead of a PdfWriter, there are some design issues to be made afaics.

      We could stil use the p:document as a base tag and add a overlay tag in that this overlay tag could take a file/url/... as an attribute and within that overlay tag we could allow a basic set of tags like page to select on which page to do overlay and within that tag we could allow text and image with postition, size, font etc to do basic things. An example for overlay would be:

      <p:document>
       <p:overlay src="/pdf/myExistingPdf.pdf">
       <p:page number="1">
       <p:text top="100" left="100" fontsize="10" fonttype="....">Hi, I'm overlayed text\n #{user.name} did this</p:text>
       </p:page>
       <p:page number="3">
       <p:image src="/jboss.jpg" top="225" left="150" />
       </p:page>
       </p:overlay>
      </p:document>
      


      or for filling out forms:

      <p:document>
       <p:form name="formId" flatten="true">
       <p:formElement name="name">#{formBean.name}</p:formElement>
       <p:formElement name="address" value="Address" />
       <p:formElement name="city" value="#{formBean.city}" />
       <p:formElement name="country">The Netherlands</p:formElement>
       </p:form>
      </p:document>


      Although the name attribute on the form element seems not to be needed (no examples with more than one form in a pdf and no api call to retrieve a specific form so there probably never is one)

      The 'flatten' attribute makes the document loose all it's input fields and just render as text (where should its' default be?)

      Any other suggestions?