function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
rajjjjrajjjj 

Not able to display visualforce as pdf

Bonojur,

 

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!!!!

 

Thanks,

Rajj

 

 

 

 

 

 

 

Bhawani SharmaBhawani Sharma

What type of data this is?

ManjunathManjunath

Hi,

 

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);

 

Regards,

 

 

Bhawani SharmaBhawani Sharma

Following up on this again:

How do you want to see this data?

Raj.ax1558Raj.ax1558
rajjjjrajjjj

 

@Bhawani

 

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.

 

 

 

rajjjjrajjjj

 

@Manjuanth,

 

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

 

ManjunathManjunath
Hi,

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

Regards
rajjjjrajjjj

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

Prashant TiwariPrashant Tiwari

Hi,

 

Please refer:

 

http://boards.developerforce.com/t5/Visualforce-Development/Options-for-Saving-VF-Page-as-PDF/m-p/688767#M69761

 

 

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

 

Thanks,

 

Prashant Tiwari