This wiki is in extension to the blog Trouble writing out a PDF in XI/PI?
The below class uses the iText library to create PDF files. The code is neither part of a java mapping nor an adapter module but is a sample that will help the reader as a reference when he/she is required to custom code in XI/PI.
1. MessageTransformBean converts the target XML to a FLAT format. The field separator is comma and the end of each record can be identified by the string literal 'END'
2. The iText library is downloaded and imported for the project.
Eg. Input format:100,Anakin Skywalker,EAS,ConsultantEND200,Darth Vader,Java,Sr. ProgrammerEND300,Obi-Wan Kenobi,MSTechmologies,Project ManagerEND Here there are 3 records and 4 fields per record.
The output PDF will have a table which will have a Main Header, followed by the header for each column of the data followed by the data itself. I have tried to experiment with some colors. Forgive my taste when it comes to being an aesthetic
The below is the code that will try capture the above requirements,
So now this is what the final output will look like;
Note: When coding for the module, write out to a Outputstream instead of a FileOutputStream