BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
HabAM
Quartz | Level 8

Hello community,

 

I am trying to create a hyperlink on a PDF document but only want to highlight the link on one word, see example below.

 

ODS PDF text="^S={font_size=9pt font_face=Arial URL='&urlPath.'}For resources and information, click here";

 

This code is highlighting the whole statement but my interest is highlighting "here".

 

How can I accomplish this without creating a separate line?

 

 

Thank you

HabAM
1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ

Hi:

  By default, ODS PDF wants the entire "cell" or your entire text string to be the link. You can't add a URL to part of a text string or just part of a cell.

 

  This Tech Support note: http://support.sas.com/kb/56/504.html explains the workaround -- you highlight the whole string, but make the link color for the string white and then "fake" a link indicator by only underlining the word(s) you want to appear as the link. Your whole string is still clickable, however.

 

  I could not find the Note, at first, when I searched, so I asked the person who supports PDF to make this note easier to find and she is going to update the keywords for this note.

 

  The note uses PROC ODSTEXT, but I applied the same technique to ODS PDF TEXT in this example:

 


ods escapechar='^';
 
** 1) test old and new style overrides for URL= compared to TS Note workaround;
ods pdf file='c:\temp\testurl_use_esc.pdf' startpage=no;
  
title link="http://www.setgame.com" 'This is a link';
title2;
  
ods pdf text="^{style[font_size=9pt font_face='Arial Unicode MS' url='http://www.google.com']1) For resources and information, click here}";
ods pdf text="^S={font_size=9pt font_face='Arial Unicode MS' url='http://www.sas.com'}2) For resources and information, click here ";
ods pdf text="^{style [font_size=9pt url='http://support.sas.com' linkcolor=white]3) Here is a URL link to the ^{style [color=blue textdecoration=underline]SAS Customer Support site}. Check it out!}" ;
  
    
proc print data=sashelp.class(obs=3);
run;
ods pdf close;

and here's the output:

pdf_url_workaround.png

 

Cynthia

View solution in original post

6 REPLIES 6
ballardw
Super User

Place the highlighting style and link information immediately before the text you want affected. Since you currently have it before "For resources ..." that is where the style goes into effect.

 

ODS PDF text="For resources and information, click ^S={font_size=9pt font_face=Arial URL='&urlPath.'}here";

HabAM
Quartz | Level 8

style.PNG

 

I tried the suggestion and it didn't create the hyperlink and the font format will not be the same for the remaining text.

HabAM
ballardw
Super User

 

Without a value for your macro variable it's kind of hard to test.

 

And it isn't clear from your initial post which text wanted which style elements.

 

HabAM
Quartz | Level 8

 

here is my macro value:

%let urlPath = %str(https://www.fda.gov/);

And I am not sure what you meant by the text style element. If you look at the screen shot I posted, the hyperlink word "here" has a different format compared to the remaining words in the text.

ODS PDF text="For resources and information, click ^S={font_size=9pt font_face=Arial URL='&urlPath.'}here";

 

 

 

HabAM
Cynthia_sas
SAS Super FREQ

Hi:

  By default, ODS PDF wants the entire "cell" or your entire text string to be the link. You can't add a URL to part of a text string or just part of a cell.

 

  This Tech Support note: http://support.sas.com/kb/56/504.html explains the workaround -- you highlight the whole string, but make the link color for the string white and then "fake" a link indicator by only underlining the word(s) you want to appear as the link. Your whole string is still clickable, however.

 

  I could not find the Note, at first, when I searched, so I asked the person who supports PDF to make this note easier to find and she is going to update the keywords for this note.

 

  The note uses PROC ODSTEXT, but I applied the same technique to ODS PDF TEXT in this example:

 


ods escapechar='^';
 
** 1) test old and new style overrides for URL= compared to TS Note workaround;
ods pdf file='c:\temp\testurl_use_esc.pdf' startpage=no;
  
title link="http://www.setgame.com" 'This is a link';
title2;
  
ods pdf text="^{style[font_size=9pt font_face='Arial Unicode MS' url='http://www.google.com']1) For resources and information, click here}";
ods pdf text="^S={font_size=9pt font_face='Arial Unicode MS' url='http://www.sas.com'}2) For resources and information, click here ";
ods pdf text="^{style [font_size=9pt url='http://support.sas.com' linkcolor=white]3) Here is a URL link to the ^{style [color=blue textdecoration=underline]SAS Customer Support site}. Check it out!}" ;
  
    
proc print data=sashelp.class(obs=3);
run;
ods pdf close;

and here's the output:

pdf_url_workaround.png

 

Cynthia

HabAM
Quartz | Level 8

Thank you Cynthia as always. 

HabAM

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 5867 views
  • 2 likes
  • 3 in conversation