Question
Cognizant
IN
Last activity: 12 Dec 2023 20:41 EST
generating PDF from Base64 encoded string
I am trying to generate a PDF document using base64 encoded string.I used the following java snippet.
String s = tools.getParamValue("Param.fileType").toString(); //Data is the base64 encoded string (Parameter) byte[] byteArray = new com.pega.pegarules.pub.util.Base64Util().decodeToByteArray(s); tools.putParamValue("PDFDocument",byteArray); String result=tools.sendFile(byteArray, "PDFDocument.pdf",false, null, true);
However it is generating a pdf and I am able to download it,but PDF is not opening ,saying incorrect "PDF is either not a supported file or file has been damaged".
Any help on this.