RTF Tags not working in HTML or PDF output.

Reply
Contributor
Posts: 46

RTF Tags not working in HTML or PDF output.

Hi All, In general most of the RTF tags will not work in other ODS destination like HTML, PDF, PS.. my questions is Do we have any options\statement or method to make it works in other ods outputs. Sample code: /* --------------------------------------------------------------------------------------- */ ods listing; ods rtf file="C:\test.rtf" ; ods escapechar= '^'; data test;     text = '^\li100 Hello '; run; proc print data=test; run; ods rtf close; ods listing; ods html file="c:\test.html" ; ods escapechar= '^'; data test;   text = "\li103 Hello " ;   test= '^R"\li100 hi"'; run; proc print data=test; run; ods html close; /* --------------------------------------------------------------------------------------- */ Thanks in advance for your Help...

Super User
Posts: 10,538

Re: RTF Tags not working in HTML or PDF output.

Depending on what you are attempting to do you may be better off genrating the RTF and then using another application to convert the RTF to HTML or PDF. Except for the specific functions related in the documentation for ESCAPECHAR and the specific output destinations supported for each, I wouldn't expect other file viewers to recognize other coding systems.

To simplify your testing code you can run multiple ods outputs at the same time:

ODS rtf file="C:\test.rtf";

ODS HTML file="C:\test.html";

ods PDF file= "C:\test.pdf";

proc print data=test;run;

ods pdf close;

ods html close;

ods rtf close;
Will send the same proc print to three different files, each in the different format.

Super Contributor
Posts: 339

Re: RTF Tags not working in HTML or PDF output.

The ods ESCAPECHAR does not appear to be designed to handle rich text format's escapes but rather to provide some additionnal formatting functions ouput device dependant.

The \li100 or left indent RTF code that you've given above could possibly be replicated for some or all output formats with different escaped functions. E.g.

text="^{STYLE CELL[WIDTH=100] Hello}";

would provide you a mean to alter the width of your column as your \li100 rtf code did in the example for other ods devices like html or most tagsets. I suggest you search sas help for ESCAPECHAR and then follow links in the STYLE function. You might be able to generate a one-fits-all code if the rtf escapes you used were only for basic formatting. However, if you were doing very complex things, your best bet is probably, as pointed by ballard, to ods rtf and use a different app to convert it or build some vba macro that you could insert in your sas code through DDE that basically opens the RTF file with a word DDE and saves it in a different format.

Vincent

SAS Super FREQ
Posts: 8,744

Re: RTF Tags not working in HTML or PDF output.

Hi,

  Ballardw is correct -- the Output Delivery System generates output for each destination. So RTF specific codes would not "work" for HTML or PDF, because RTF is specific to word processors -- since it was designed as a way for Microsoft Word to exchange word processing files with other word processors.

  However, there are some ODS ESCAPECHAR functions that will work in all 3 primary destinations. You just have to figure out whether what you want to do can be done with ODS ESCAPECHAR or with regular ODS styles. For example, your \li command is used for indenting is not the only way to do indenting. SAS and style overrides can do indenting for RTF and PDF using regular style overrides with the LEFTMARGIN style attribute. But, the LEFTMARGIN attribute doesn't work for HTML. So, sometimes you just have to know the type of markup that goes with your destination, if your destination has markup and then use that method.

  If you run the code below, you will see that the HTML column for NAME is not indented in the first example, but -is- indented in the second example. In the second example, you have to use the HTML named entity for a non-breaking space (which doesn't show up correctly here).

cynthia

ods rtf file='c:\temp\showesc.rtf';

ods pdf file='c:\temp\showesc.pdf';

ods html file='c:\temp\showesc.html' style=sasweb;

ods escapechar='^';

 

proc report data=sashelp.class nowd;

  title '1) This is ^{style [foreground=red]RED} in the title';

  title2 '2) ^{style[textdecoration=underline]underline} in the title';

  title3 '3) HTML will not be indented';

  column name age height weight sex;

  define name / 'Name'

    style(column)={width=2in leftmargin=.5in};

run;

    

ods _all_ close;

   

ods html file='c:\temp\showesc2.html' style=sasweb;

ods escapechar='^';

   

proc report data=sashelp.class nowd;

  title '1) HTML WILL be indented';

  column name age height weight sex;

  define name / 'Name'

    style(column)={width=2in protectspecialchars=off

                   pretext='<-- put HTML code here for indenting -->'};

run;

  

ods _all_ close;

title;


use_nbsp_html.png
Contributor
Posts: 46

Re: RTF Tags not working in HTML or PDF output.

Dear All,

Thanks for your suggestions.

Hi Cynthia..

The idea of using &nbsp is good. But would it be possible to include a piece of code or TAG in the dataset itself rather than using pretext='<&nbsp>'...

I need the indent code in dataset,


data test;

  text1 = "\li100 Hello " ;  /* For RTF - this will work*/

  text2 = " ??? Hi";    /* for HTML & PDF - ???> */

run;

The Reason why I need it in dataset is I have to generate a Table as below where indentation is not required for the first row but not for the second third....It is kind of Stacking (AE table).

All SOC....

     SOC1

     SOC2

ALL PT

    PT1

    PT2....

Thanks in Advance.

Ask a Question
Discussion stats
  • 4 replies
  • 630 views
  • 3 likes
  • 4 in conversation