+ Start a Discussion
rforce2rforce2 

Render Blob which represents a pdf using visualforce page

Is it possible to return blob from controller to page?

 

Page:

 

<apex:page contentType="application/pdf" controller="VFBlobTest">{!pdf}</apex:page>

Controller:

 

 

public with sharing class VFBlobTest {
   public static Blob getPdf(){
      Blob result = SomeWebServiceCalloutThatReturnsBlob();
      return result
   }
}

The example I gave is what I would like to happen, but it won't work. It neither works with String.

 

Any work around?

 

 

servlet.FileDownload is not an option, because I can't store the file in the ORG. 

Alok_NagarroAlok_Nagarro

Hi,

Try this...

 

<apex:page  controller="VFBlobTest" renderAs="pdf">

{!pdf}

 

</apex:page>

 

Thanks,

Pradeep_NavatarPradeep_Navatar

I think you can change Blob type to string type by using the code given below to achieve your requirement :

 

public with sharing class VFBlobTest

{

    public string getPdf()

    {

    String s = String.ValueOf(SomeWebServiceCalloutThatReturnsBlob());

    return result

    }

}

 

Hope this helps.

DPacDPac

I have a question on this, when you use valueOf or toString method on Blob to convert to String is there a limit on char or bytes? If truncation does occur what is the limit?