At this stage, we know that there is no straightforward method (like File Layouts to generate basic excel documents) to create PDF documents from Peoplecode. We have to make use of open source libraries like iText to generate PDF documents. Now, within PeopleCode there are two approaches to generate a PDF document;
1) Load the iText jar file to the classes folder and use PeopleCode / Reflection techniques to push data to PDF files -> This approach is complicated and often results in creating multiple JavaObjects before ending up with the PDF document. If you are looking to generate plain PDF documents with very less data for emailing or short reporting purposes, then this approach can be used. The PDF document should be a fairly simple for generation.
2) Write a Wrapper Class for iText: To eliminate the complexities in creating PDF documents, you can afford to write a wrapper class and call the iText methods inside the wrapper class. You can then invoke the methods on the wrapper class from PeopleCode, which would definitely eliminate the complexities in creating PDF documents directly from PeopleCode. We saw this in the iText PDF table example, where for adding a cell to the PdfPTable object, we had to go on a wrapper class approach, which helped to hide complexities.
In the two approaches listed above, we create the PDF document in real time, directly from PeopleCode. This can be useful if you want to email the resulting PDF document as a report and so on. There can be a possible third approach to generate PDF documents from PeopleSoft. In this approach, we can hide the entire complexity of creating PDF document via Application Server / Process scheduler (Application engine programs). Instead, the user can construct an XML message and post it as an outbound request to the PeopleSoft Integration Gateway. You can then write a custom connector class, which will handle the request when published to the Gateway. This class can direct the call to a Java class which will create a PDF document. The fallback of this approach is that the PDF document may sit in a different server (depending on the integration gateway configuration), and to pull it from the application layer, an FTP approach may be required. But this method is good in once sense; it creates PDF in the way Java generates, and there is no communication between PeopleCode and Java often. This moves all the complexity out from PeopleCode and it requires only an XML from PeopleSoft to accomplish the task. However, you need to write a connector class for this in PeopleSoft.
In Batch mode, you can also think of pushing the required inputs for PDF creation in a table in PeopleSoft. From there, you can invoke a Java Crontab program, which can poll through the table and create the PDF document for your application. The Crontab will have to poll through the table in real time or near real time if you want an instant PDF generation. There is no connected relationship here to generate PDF. There are no isolated entities linked by a table to generate PDF and I don’t recommend this approach personally.
Do you have a different approach to generate PDF files from PeopleSoft? Share it..
No comments:
Post a Comment