You need to sign in to do that
Don't have an account?
NareshKrishna
How can we download string as file in visualforce ?
Hi All,
How can we Download String variable defined in controller as text file using visualforce ?
Could anyone help me with this.
Thanks.
You should be able to do this by having a page that contains the string and specifying the contentType attribute. Something like:
All Answers
You should be able to do this by having a page that contains the string and specifying the contentType attribute. Something like:
Bob's solution is correct, so accepting it as solution.
Thanks bob :)
Hi,
In the same way, I tried to download image as png format.
Code used to download image as png:
<apex:page contentType="image/png#samplelogo.png" >
<apex:image url="http://ap1.salesforce.com/img/seasonLogos/sales_logo_aloha_spr12.png" />
</apex:page>
With above code able to download file in png format but image not available in the downloaded file.
Code used to download image as html:
<apex:pagecontentType="text/html#samplelogo.html">
<apex:image url="https://ap1.salesforce.com/img/seasonLogos/sales_logo_aloha_spr12.png" />
</apex:page>
With above I can able to download and view the image.
But I need to download the image as png or jpeg format.
Could you please help me with that?
Thanks.
apex:image renders HTML. You'll need to write the actual content of the image file as the body of that page. I'm afraid that's not something I've done before. How are you accessing this page though? If its via a link you should be able to make the target of the link the image.
I am accessing page directly from broser:
https://c.ap1.visual.force.com/apex/DownloadExp
But presumably you aren't just sitting down and typing that link in. Are you clicking on a link from another page, or out of an email for example?