The SAS Output Delivery System and reporting techniques

ODS PDF hyperlink

Accepted Solution Solved
Reply
Contributor
Posts: 42
Accepted Solution

ODS PDF hyperlink

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


Accepted Solutions
Solution
‎10-13-2017 05:38 PM
SAS Super FREQ
Posts: 9,251

Re: ODS PDF hyperlink

[ Edited ]

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


All Replies
Super User
Posts: 12,994

Re: ODS PDF hyperlink

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";

Contributor
Posts: 42

Re: ODS PDF hyperlink

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.

Super User
Posts: 12,994

Re: ODS PDF hyperlink

 

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.

 

Contributor
Posts: 42

Re: ODS PDF hyperlink

 

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";

 

 

 

Solution
‎10-13-2017 05:38 PM
SAS Super FREQ
Posts: 9,251

Re: ODS PDF hyperlink

[ Edited ]

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

Contributor
Posts: 42

Re: ODS PDF hyperlink

Posted in reply to Cynthia_sas

Thank you Cynthia as always. 

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 6 replies
  • 574 views
  • 1 like
  • 3 in conversation