- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi, I wonder how to change the background color of a text string via ODS PDF. It works at ODS RTF, but I don't know why it does not work at ODS PDF. Here is the code:
data aaa;
a=cat('abc',"^{style[backgroundcolor=pink foreground=red]defg}","hi");
output;
a=cat('abc',"^{style[background=pink foreground=red]defg}","hi");
output;
run;
ods escapechar='^';
ods pdf file="test.pdf";ods rtf file="test.pdf";
proc print data=aaa;
run;
ods _all_ close;
The ODS RTF output returns this, and that is what I want: red text with pink background.
But ODS PDF output returns just red text, background color does not change.
Can anyone show me any issue from my code? Thanks!
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Yes, @jimbarbour's choice b is the answer. I always explain it to my students this way when they ask if something is possible (like can I change the page number to the bottom of the page) -- The answer is "It depends on the destination" -- RTF and PDF -- yes; HTML -- No, ODS Excel, yes, but you have to use Microsoft specific field codes to do it.
The way I understand PDF is that PDF "wants" the background color to apply to the entire data cell. So foreground color for part of the string is OK. But background color doesn't work for inline formatting because PDF wants the whole cell to have the same background. It's different for RTF and Word because, well, Microsoft.
Cynthia
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I ran your code and got the same results. I used two different means to open the pdf, so I don't think it's your pdf reader that is at issue.
The fact that the code works for one ODS destination but not another suggests that one of the following may be true
a) there could be a bug in the SAS software
b) this feature just isn't supported in pdf
I don't really know which it is in this case. @Cynthia_sas seems to know a lot on this subject. Perhaps if she has time she can weigh in.
Jim
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Yes, @jimbarbour's choice b is the answer. I always explain it to my students this way when they ask if something is possible (like can I change the page number to the bottom of the page) -- The answer is "It depends on the destination" -- RTF and PDF -- yes; HTML -- No, ODS Excel, yes, but you have to use Microsoft specific field codes to do it.
The way I understand PDF is that PDF "wants" the background color to apply to the entire data cell. So foreground color for part of the string is OK. But background color doesn't work for inline formatting because PDF wants the whole cell to have the same background. It's different for RTF and Word because, well, Microsoft.
Cynthia
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thank you, @Cynthia_sas. It's about time somebody showed up around here who actually knows what they're talking about...
Jim