Monday 15 February 2021

How to download Base64 pdf file by using Pega Activity

Hi Friends, In this post we will see how to download a file which is in base 64 encoded format.


URL to get encoded format of a file : https://base64.guru/converter/encode/file


Selected a pdf file from my local system and click encode file to base 64 button to get encoded data of the file.

Created a sample activity VerifyWork, in that called an pega activity named View of Code-Pega-PDF class.






This activity use is to download the base 64 format pdf file .

For this activity we have to provide 2 parameters,

PDFName - in which name the pdf file should download
PDFDocument- base 64 format of pdf file.

Added Java step to decode base 64 into byte array.



Java code:

String S = tools.getParamValue("PDFDocument").toString();
byte[] byteArray =  new com.pega.pegarules.pub.util.Base64Util().decodeToByteArray(S);
tools.putParamValue("PDFDocument",byteArray);

Lets run the activity and verify our work.



We can see the pdf file is downloaded on running the verifywork activity. 

Hope this topic understandable to everyone. Comment if you have any doubts.

5 comments:

  1. This comment has been removed by the author.

    ReplyDelete
    Replies
    1. Pega Learnings: How To Base64 Pdf File By Using Pega Activity >>>>> Download Now

      >>>>> Download Full

      Pega Learnings: How To Base64 Pdf File By Using Pega Activity >>>>> Download LINK

      >>>>> Download Now

      Pega Learnings: How To Base64 Pdf File By Using Pega Activity >>>>> Download Full

      >>>>> Download LINK OW

      Delete
    2. It works good. Thanks for the post. How to open base64 code as url in new window with contents alone. I don't need to download as pdf. Just i need to view as content in new tab. Could you please help me on this.?

      Delete
  2. Pega Learnings: How To Base64 Pdf File By Using Pega Activity >>>>> Download Now

    >>>>> Download Full

    Pega Learnings: How To Base64 Pdf File By Using Pega Activity >>>>> Download LINK

    >>>>> Download Now

    Pega Learnings: How To Base64 Pdf File By Using Pega Activity >>>>> Download Full

    >>>>> Download LINK PY

    ReplyDelete