Hi,
Has anyone successfully brought in an external gif/png image with a transparent background and gotten it to work as expected?
I have an ODS LAYOUT region with a colored background, and tried to drop a png image file on to it that has a transparent background. I want the underneath layer to show through the transparent part. Target is a PDF file.
I'm not sure if it is the .png file or what I'm doing in SAS.
Thanks!
--Ben
It might help to show the code you have that involves the ODS statement and the procedure(s) that reference the PNG file so we have some details to discuss to consider.
Also the version of SAS you are running might be a factor.
It depends on what procedures you are using for graphics. Here are many examples using transparent images with SGPLOT procedure: http://blogs.sas.com/content/graphicallyspeaking/?s=transparent+images
I was running a sample program:
dm 'clear log';
ods escapechar='^';
ods PDF file="&path.test.pdf" notoc;
ods layout absolute y=.25in x=.25in width=10.5in height=8in style={background=green};
ods region width=10in height=7in;
ods text = "^{style[background=blue postimage='&impath.test.png'].}";
ods layout end;
ods pdf close;
With the attached test.png; orientation was landscape. Was expecting the cyan hexagon to have a green background and the surrounding rectangle to be either blue or green. It was magenta, which was the color I had tried to set to transparent.
--Ben
Oh..am on 9.4 TS1M3. Sorry.
---Ben
@BenConner wrote:
With the attached test.png; orientation was landscape. Was expecting the cyan hexagon to have a green background and the surrounding rectangle to be either blue or green. It was magenta, which was the color I had tried to set to transparent.
Perhaps the plot thickens: How did you attempt to set the magenta to transparent? Does that image appear transparent when viewing it in other applications or viewers?
This link
http://stackoverflow.com/questions/14220221/how-to-insert-transparent-png-in-pdf
may shed some light in general about PNG, transparency and PDF.
Interesting post. So apparently png files aren't natively compatible with PDF files. How about gifs?
--Ben
Good morning,
It does appear it was an issue with how the transparency layer was defined in the image. Used a different graphics package that I know better and it worked as advertised. Including as a .png file.
Sorry for the confusion!
--Ben
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.