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
C0C0 

Image servlet (aka binary data in VF)

Is it still impossible now? We have a few new options to surpress the output of tags.

Best Answer chosen by Admin (Salesforce Developers) 
sfdcfoxsfdcfox
<apex:page controller="svg" applyBodyTag="false" applyHtmlTag="false"
    showheader="false" sidebar="false" standardStylesheets="false" contentType="image/svg+xml">
    <apex:outputText value="{!output}" escape="false"/>
</apex:page>

 

public with sharing class svg {
    public string output { get; set; }
    public svg() {

        output = '<svg xmlns="http://www.w3.org/2000/svg" version="1.1"><rect width="300" height="100" style="fill:rgb(0,0,255);stroke-width:1;stroke:rgb(0,0,0)" /></svg>';
    }

}

This works in my Chrome browser, for example, and probably works in IE9+, but not older browsers.

All Answers

sfdcfoxsfdcfox
We can't emit binary data, so only text-based image formats will work correctly. For example, you can output SVG files to a browser, and if the browser supports it, it will be rendered correctly. Older versions of IE won't support this, but most modern browsers will.
sfdcfoxsfdcfox
<apex:page controller="svg" applyBodyTag="false" applyHtmlTag="false"
    showheader="false" sidebar="false" standardStylesheets="false" contentType="image/svg+xml">
    <apex:outputText value="{!output}" escape="false"/>
</apex:page>

 

public with sharing class svg {
    public string output { get; set; }
    public svg() {

        output = '<svg xmlns="http://www.w3.org/2000/svg" version="1.1"><rect width="300" height="100" style="fill:rgb(0,0,255);stroke-width:1;stroke:rgb(0,0,0)" /></svg>';
    }

}

This works in my Chrome browser, for example, and probably works in IE9+, but not older browsers.

This was selected as the best answer
C0C0

Too bad SVG support is non-existence in email clients :) thanks mate