Question
2
Replies
6232
Views
Infosys
Posted: June 13, 2017
Last activity: June 13, 2017
Closed
How to Parse a binary file in Pega (Rule-File-binary) file extension can be (.pdf,.excl,.msg) need source code (java)
How to Parse a binary file in Pega (Rule-File-binary) file extension can be (.pdf,.excl,.msg) need java Code
***Moderator Edit: Vidyaranjan | Updated Categories***
You can get the Bytes of the file you need using the following steps
In a PRPC Activity:
1. Use 'OBJ-OPEN' for the instance of the Binary File that you wish to access.
2. The property 'pyFileSource' will contain the Binary Data (Base64 encoded format).
3. You can use the OOTB PRPC Function "Default.Base64Decode" to convert this to bytes (via a Java String).
If you have a mixture of PDF, EXCL, MSG etc - then you will need to parse them using an appropriate Java Library (so for instance Apache POI for EXCEL, MSG), and Apache PDFBox or iText for PDF.
The Java code needed will vary depending on exactly what you need to parse out; but there are some examples in these Forums already that use these libraries (and there are plenty of examples on third-party sites for using these libraries in general - they are all well known libraries).