Question
Nordea
SE
Last activity: 11 Oct 2021 5:14 EDT
Base64 to PDF
Hi,
I am getting a Base64 encoded string from one of the external system and the same needs to be converted into PDF. I tried passing that string into HTMLtoPDF activity but when i view the PDF, it's corrupted. I also tried to Decode the content first using Base64Decode function but it still shows me the error. Can someone tell me the way i can convert the Base64 string to PDF?
***Edited by Moderator: Lochan to update platform capability tags***
-
Like (0)
-
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
Accepted Solution
Nordea
SE
Just tried the below java before calling Code-Pega-PDF.View Activity and it worked for me:--
String s = tools.getParamValue("Markup").toString(); //markup is the base64 encoded string
byte[] byteArray = new com.pega.pegarules.pub.util.Base64Util().decodeToByteArray(s);
tools.putParamValue("PDFDocument",byteArray);
Pegasystems Inc.
IN
Hi Anand,
You may need to review following article:
https://community.pega.com/knowledgebase/articles/use-base64-encoding-send-pdf-files-or-images-soap-message
Do let us know if this helps.
Nordea
SE
The article you have shared is related to sending PDF file in SOAP message. However my requirement is to convert Base64 to pdf files and then attach it with the case. I guess the above article won't help much on my case.
Accepted Solution
Nordea
SE
Just tried the below java before calling Code-Pega-PDF.View Activity and it worked for me:--
String s = tools.getParamValue("Markup").toString(); //markup is the base64 encoded string
byte[] byteArray = new com.pega.pegarules.pub.util.Base64Util().decodeToByteArray(s);
tools.putParamValue("PDFDocument",byteArray);
-
Holger Velte JC Romero Petros Papakostas ARIJIT SEN Vinay Lakka
Adaps
IN
Yes it got worked for me also
-
Wojtek Nowak Mahesh Kharde Justin Gaupp Matt Geiger Engincan Yildiz and 3 More
Ernst & Young LLP
IN
It's generating a PDF but the PDF is not opening, throwing 'unable to open it' error.
Are you albe to open it?
Pegasystems Inc.
IN
Hi,
Thank you for posting your query in the PSC. This looks like an inactive post and hence, we suggest you create a new post for your query. Click on the Write Post button here. Once created, please reply back here with the URL of the new post.
You may also refer this discussion link as a reference in the new thread.
Optum Clinical Solutions Inc
IN
Hi Prateek,
I am also getting the same error. Did it worked for you after doing any change ?
Thanks,
Maruthi
HCL
IN
Its working only once.
Nordea
SE
You mean evertime you generate pdf second time, it doesn't work? or it's not working anymore at all?
Thryve Digital Health LLP
IN
Hi, I am also trying to convert base64 encoded string to PDF. I have tried doing it by using the above java code but i am unable to open it. It is saying file is corrupted. Can you please let me know if you have done something else apart from the java code.
Pegasystems Inc.
US
Thanks for writing a new post Sandeep! I see that you received a reply.
You can view it here!
Thanks!
Marissa | Collaboration Center Moderator | Pegasystems Inc.
HCL
IN
Second time its not working
Biz Arch Solutions Inc
US
Hi Anand, I had exactly the same requirement i have copied your code but the PDF is corrupt. I am setting the base64 endocded string into param.Markup and then wrote a java step with below lines.
String s = tools.getParamValue("Markup").toString(); byte[] byteArray = new com.pega.pegarules.pub.util.Base64Util().decodeToByteArray(s); tools.putParamValue("PDFDocument",byteArray);
Followed by the Java step i called HTMLToPDF by passing current parameter page and then called View activity by passing current param again.
PDF got corrupt.
-
Yuvasaivarun mandadapu
Updated: 10 Apr 2020 2:21 EDT
Thryve Digital Health LLP
IN
Hi All, I have solved this issue. I am able to convert Base64 Data to PDF file and also attach it to the work object. Please find the detailed steps in the attached file.