+ Start a Discussion

Not able to display visualforce as pdf



I am getting some content from an external webservice and trying to display as a pdf file.


As a response I am getting a String and I have decoded the string using EncodingUtil.base64Decode(response) and assigned it to a blob variable.


Now I am trying to print that blob variable in vf page using renderAs pdf and instead of rendering as pdf it is displaying in bytes as core.filemanager.byteblobvalue@23F6123c


I have tried using Blob.toPdf() and Blob.valueOf() to get a pdf output.

And also I dont want to save it as an attachment in salesforce..because it may create excess attachments.

Saving as an attachment is working fine and displaying as pdf.


Any suggestions would be appreciated!!!!











Bhawani SharmaBhawani Sharma

What type of data this is?




Try this.

1 .Convert string to blob using this

      Ex: Blob SValue= Blob.valueof('My string');

2. Next convert it back to string as 

      Ex : String BValue = EncodingUtil.base64Encode(SValue);





Bhawani SharmaBhawani Sharma

Following up on this again:

How do you want to see this data?





I think I am getting a Base64-Encoded String as a Response. So I am doing(decoding) like this:


Blob blobValue = EncodingUtil.base64Decode(response.Response);


And if I am using blobValue as body of an attachement and inserting it, I am able to get the pdf.

If I am directly accessing it without inserting as an attachement, then it is not displaying as a pdf, it is showing as core.filemanager.byteblobcode@....


What I am thinking is may be we need to decode the response like this:


response1 =response.Response;

response2 = EncodingUtil.urlEncode(response1 ,'UTF-8'); //then encode it into utf-8 format and then convert into blob

blobValue2 = Blob.toPdf(response2);


Something like this, but it is not working.








After 2nd step, Do I need to convert it to blob again to display it as a pdf(the output should come as an image)


Blob blobValue2 = Blob.valueOf(response2);


I have done like this:


Blob blobValue = Blob.valueOf(response);
String response2 = EncodingUtil.base64Encode(blobbb); //If i am displaying this string it is coming as some text in one line.
Blob blobValue2 = Blob.valueOf(response2); //if i am printing this it is coming as core.filemanager.byteblobvalue@23F6123c



Explain me the scenario. It might help me understand better.


Can you read my first post. That explains the scenario.

Prashant TiwariPrashant Tiwari



Please refer:





***mark it as solved if the solution worked as it might help others !!




Prashant Tiwari