The SAS Output Delivery System and reporting techniques

ods pdf: Left justify image and center text in a header?

Reply
Contributor
Posts: 53

ods pdf: Left justify image and center text in a header?

Hi guys, I'm having some trouble...

I'm outputting a pdf via ods and I want to put an image justified left in the header with text centered to the right like this:

|-----------------|
|-----------------| This is the title1
|-----------------| This is title2
|-----------------|
|-----------------|

any help would be appreciated!

Message was edited by: FrankE

Message was edited by: FrankE

Message was edited by: FrankE

Message was edited by: FrankE
SAS Super FREQ
Posts: 8,868

Re: ods pdf: Left justify image and center text in a header?

Hi:
Try this (without an image):
[pre]
title1 j=c 'Centered Title';
title2 j=l 'Left' j=c 'Another Thing';
title3 j=l color=red 'Left' j=c h=16pt 'Center' j=r c=green 'Right';
[/pre]

The justification attribute can be used on a TITLE statement to alter the justification of separate text strings. In addition, you can specify multiple strings and multiple justifications....and multiple colors and sizes. The attribute that you are changing must precede the string that you want to impact.

For an example of using an image in a TITLE statement, see this previous forum posting:
http://support.sas.com/forums/thread.jspa?messageID=5882᛺

cynthia
Contributor
Posts: 53

Re: ods pdf: Left justify image and center text in a header?

Posted in reply to Cynthia_sas
Thanks for your help.

The issue I'm having is getting the text to center vertically and horizontally with the image...

I have:

title1 j=l '^S={preimage="D:\Images\ABA_blue_trans.jpg"} ' j=c 'Test Text';
title2 j=c 'Line2';

"Test Text" is in line vertically with the bottom of the image and "Line 2" is below the image. How do I get the text to center vertically with the image?
Contributor
Posts: 53

Re: ods pdf: Left justify image and center text in a header?

Here's a paper I found where the examples are exactly what I want. Logo on the left, text to the right centerd vert and horiz with the image... however the code snippits don't produce the same result for me Smiley Sad

http://www2.sas.com/proceedings/sugi29/157-29.pdf
SAS Super FREQ
Posts: 8,868

Re: ods pdf: Left justify image and center text in a header?

Hi:
Example 1 uses RTF and a custom style template designed specifically for RTF and the description implies that the template contains RTF specific instructions ... so, I wouldn't expect the RTF example to work for PDF or HTML output.

Example 2 uses ODS PDF and ODS LAYOUT. ODS LAYOUT is experimental or "pre-production" and depending on what version of SAS you have, may or may not work for you as it did in her example.

When I use code, such as what's shown below, however, I -do- see the center text strings middle justified in the space taken up by the image of Kermit. The Escapechar+S (~S in my code) is specifying a vertical justification of Middle for the text strings that follow it and the Escapechar+N (in this case ~n) represents a line feed or carriage return every time it appears in a text string. Note that the escapechar that I declare in the ODS ESCAPECHAR statement must be the same as the ESCAPECHAR I use in my text string.

The only other reason I can think of for you to have issues is if you are trying to use an image along with the Page X of Y page numbering. In some instances, I think those 2 combos can give you problems.

cynthia
[pre]
ods pdf file='c:\temp\logo_labelx.pdf';
ods escapechar='~';
title j=l '~S={preimage="c:\temp\kermit.gif"}'
j=c '~S={vjust=m} 1) Title line 1~n Another Line~n A third line';

proc report data=sashelp.shoes(obs=6)nowd;
column region product sales;
define region / 'Region';
run;

ods pdf close;
[/pre]
Contributor
Posts: 53

Re: ods pdf: Left justify image and center text in a header?

Posted in reply to Cynthia_sas
And that worked perfectly! Thanks so much! I've been beating my head against this all day! So funny how I spent hours and the solution is literally 2 lines long. lol. Thanks again!
Ask a Question
Discussion stats
  • 5 replies
  • 1722 views
  • 1 like
  • 2 in conversation