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
ColdfingerColdfinger 

Stripping <HTML> tags from APEX

Hi, a bit new to all of this,

 

I'm attempting to create a VisualForce page which literally writes a text file, with no HTML tags at all, for use with some legacy scripts we have in place that require this format.  This is eventually going to be filled with some information from an accounts record, but I'm testing without at the moment

 

<apex:page sidebar="false" showheader="false">
  <h1>Congratulations</h1>
</apex:page>

 

Unfortunately when viewed in a browser, this is adding the html around the outside

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

  <html><head></head><h1>Congratulations</h1></html>

 

Is there any way in apex to suppress the automatic formatting with this html that gets added in?

 

Thanks in advance

Best Answer chosen by Admin (Salesforce Developers) 
JimRaeJimRae

use the contenttype parameter on the page tag.

 

Something like this:

 

 

<apex:page sidebar="false" showheader="false" contenttype="text/plain"> <h1>Congratulations</h1> </apex:page>

 

 

 

All Answers

JimRaeJimRae

use the contenttype parameter on the page tag.

 

Something like this:

 

 

<apex:page sidebar="false" showheader="false" contenttype="text/plain"> <h1>Congratulations</h1> </apex:page>

 

 

 

This was selected as the best answer
ColdfingerColdfinger

Thanks, that's perfect, I had to bring the < > in tight against each other or it added spaces as well

 

<apex:page sidebar="false" showheader="false" contenttype="text/plain"><h1>Congratulations</h1></apex:page>