<fo:table-row background-color="#FFFFFF">
		<fo:table-cell border-style="solid">
		  <fo:block  ><dynamic-data:parameter value="iter=varTest@Row/FirstName" valueType="String"/></fo:block>
		</fo:table-cell>
		<fo:table-cell border-style="solid">
		  <fo:block  ><dynamic-data:parameter value="iter=varTest@fund/LastName" valueType="String"/></fo:block>
		</fo:table-cell>
	  </fo:table-row>
</dynamic-data:for-each>


Iterative while block.<dynamic-data:while> Loop while the condition defined in the attributes evaluates to true. The definition of the condition and comparison uses the same syntax as the element. The content inside the element is added each time the condition evaluates to true.

Examples:

<dynamic-data:while value="var=varSequence" valueType="Integer" compType="lteq" compValue="const=5" compValueType="Integer">
	<fo:block>INSIDE OF A WHILE=<dynamic-data:parameter value="var=varSequence" valueType="Integer"/></fo:block>
	<dynamic-data:action value="action=increaseVarSequence"/>
</dynamic-data:while>

Execution of WEF action without producing output. <dynamic-data:action> Execution of an action in the WEF model. It does not produce any output in the PDF. The syntax for the value attribute is the same as the common value attribute for actions.

Examples:
<dynamic-data:action value="action=myCustomAction"/>
<dynamic-data:action value="action=increaseVarSequence"/>


Images in PDF. There are two types of images in a PDF: Static and Dynamic.
  • Static images: Can be referred to as “servlet-context:/path of image”. For example:
<fo:external-graphic src="servlet-context:/images/ibm-logo.jpg"/>
  • Dynamic images: In Apache FOP it's not possible to assign a byte array in the <fo:external-graphic > element, so we need to a get byte array, convert it into Base64-encoded string, and then assign it to element. By using this functionality you can retrieve an image from WCM or any other system and add it to the PDF.

Example:
<fo:external-graphic src="dynamic-image:varBase64EncodedImageString"/>


Examples and learning


There is a set of examples under the attached project archive. This archive can be imported at any WEF project. It contains one model to test static (without extended elements) and dynamic generation of PDFs. The dynamic PDF contains a good set of test cases of the extension elements (parameters, conditions, iterations, etc.).

Table 1 lists the resources within the Samples project and their descriptions (paths are relative to /WebContent):

Table 1. Resources within Samples project
Resource
Description
/pdf_templates/ DynamicPDF.fo
XSL-FO file which generates a PDF with dynamic content from the WEF model.
/WEB-INF/models/samples/ PDFCreatorSample.model
Sample model that uses the PDF Creator builder. Demonstrate the capabilities of the builder and how to use it.

Troubleshooting


If the custom builders are not in the list of all builders when you verify their presence, repeat the installation steps to ensure that all the files are copied into the correct locations or archive imported properly.

If you find multiple errors in the Problems view after you import the sample model, such as “BuilderDef not found,” verify that PDF Builder custom builders is in the builder call list.

Some other troubleshooting tips include restarting WEF Designer, creating a new workspace, and creating a new model.

Removing the custom builders
To do this, just remove the files that were copied or extracted during the installation.

Conclusion


You should now be able to create custom solutions for building PDFs effectively, using Web Experience Factory builders. This article has provided the detailed instructions on how to use PDF builder and PDF generation with dynamic data.

Resources


developerWorks IBM Web Experience Factory product page:
http://www.ibm.com/developerworks/websphere/zones/portal/portletfactory/

IBM Web Experience Factory customer discussion forums:
http://www-01.ibm.com/support/docview.wss?rs=3044&uid=swg27011853

About the author


Vinayak Patil is a WebSphere Portal Specialist with IBM India Software Labs, currently working for the Lab Services division. He specializes in WebSphere Portal, IBM Mobile Portal Accelerator, WEF, IBM Web Content Manager, and IBM Forms and participates in various customer-facing engagements. You can reach Vinayak at vinayspa@in.ibm.com.


Disclaimer
The custom builders and sample model furnished with this article are provided as-is and are not supported by IBM. For this reason, IBM Technical Support is no able to answer questions about these custom builders.