Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
Shabarish_Nair
Active Contributor
0 Kudos

In an earlier blog, I tried to capture the various alternatives of Excel Files - How to handle them in SAP XI/PI (The Alternatives). In this blog the focus will be on PDF Files.

 

Let me first try and document some of the options that we already know through SDN.

 

1. Obviously Mr. Conversion Agent - Capable of literally taking any kind of data in and transforming out into any data. PDFs, the bugger processes them too 🙂

2.  XSL-FOP and the Apache FOP way - It is described as per this XI: Generate PDF file out of file adapter

3. Now some other work arounds to achieve our objective is use of Java proxies and executing scripts which I havnt tried yet. 

But then what I have tried and would like to recommend is the use of a very simple JAVA library I tumbled upon while doing some R&D on this front.

 

iText is a free java PDF library. You can read about the library and download the jar file from here

 

Lets take a typical scenario (I think I will take the exact one I used for the Excel development). So here you have a bunch of employee details that needs to be written out to a PDF format. We need to have tables and lets put in some simple formatting, you know add some colours and stuff 🙂

 

Anyway, the simplest design I propose is to have your mapping done, create the target XML with the employee details and then pass this to the Adapter (FILE/MAIL etc). Now use the MessageTransformBean and convert the XML to a FLAT format. Now insert your custom module with the code to create the PDF. The advantage I find here is that you have your inputstream in a flat string and its very easy to do string manipulations.

Well if you dont use the MessageTransformBean then in the module you will have your target XML as input and then you know go through the hustle and buzzle to parse it and then... well I really dont want to do down that path cos I aint that brave enough. So I will stick to my simple to use String functions and leave the parsing to the standard bean by SAP.

 

So to summarize, the message flow I propose is

Target XML -> Adapter -> MessageTransformBean -> Our Custom Module

It is all quite similar to the earlier Excel story I wrote, aint it? Only thing that changes towards the end is the library that will do the trick, the conversion of the inputstream to a PDF format.

 

I have created a Wiki that will show you the code that will demonstate the ease of use of this particular library.

Click Here for more details.

 

Hope this blog provides you insight into options that you can work on and suit your requirements when it comes to PDFs in XI/PI. Exploring the iText library you will also find various interfaces and methods to help you read a PDF also. Maybe when the time of need arises, you can have a look and explore more 🙂

10 Comments
Labels in this area