Hi I am trying to create a PDF hyperlink using t.format_cell method. But one the URL path contains '#' symbol and because of it the hyperlink generated becomes invalid. And the URL generated do not contain the text/path after '#' symbol.
In the example below, the actual File path is 'file:///test/file/path/Information #51801.msg' but in PDF generated it is 'file:///test/file/path/Information '
Code:
%let file_name ='Additional Information';
%let url_path = 'file:///test/file/path/Information #51801.msg';
proc template;
define style work.sample;
parent=styles.pearl;
style TableBase/
cellpadding=2pt
verticalalign=top
;
style TextUnderline from Body /
borderbottomcolor=black
borderbottomwidth=1pt
textindent=10
height=20pt
fontsize=8pt
;
end;
run;
%put %STR(NOTE: Build the report ... );
ods escapechar='~';
%let outpath=/sas_data/pdf_location;
ods pdf
file="&outpath./output_file.pdf"
;
ods trace on/ label;
data _null_;
declare odsout t();
t.table_start( name: 'Attachments', style: 'TableBase', overrides: 'width=190mm');
t.row_start();
t.format_cell(Text: "" );
t.format_cell(text: &file_name
, style: 'TextUnderline'
, url: &url_path, overrides:"color=blue"
,overrides:'');
t.row_end();
t.table_end();
run;
ods pdf close;
I think the problem is the embedded blank not the # sign. Try getting rid of the embedded blank.
Jim
Hi Jim,
Thanks for responding. No it did not work, the black space is getting parsed without issue, but when it comes to '#' symbol, it get cutoff.
Actual URL Path - 'file:///test/file/path/Information doc#51801.msg'
URL in PDF - 'file:///test/file/path/Information doc'
URL generated in PDF,
Thanks,
Soundappan
From the wikipedia article for URL/URI:
#
). The fragment contains a fragment identifier providing direction to a secondary resource, such as a section heading in an article identified by the remainder of the URI. When the primary resource is an HTML document, the fragment is often an id
attribute of a specific element, and web browsers will scroll this element into view.As you can see, the hash sign has a special meaning in URI's and must not be used for anything else.
(When you define an anchor in a HTML page, the # syntax is used to place the browser directly there)
Bottom line: don't use special characters in filenames, unless you want to run into trouble later.
@Soundappan wrote:
Thanks for responding. No it did not work, the black space is getting parsed without issue, but when it comes to '#' symbol, it get cutoff.
Actual URL Path - 'file:///test/file/path/Information doc#51801.msg'
URL in PDF - 'file:///test/file/path/Information doc'
Interesting. Well, I think @Kurt_Bremser's admonition to not use a "#" symbol because it has special meaning is probably sound.
Jim
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.