BookmarkSubscribeRSS Feed
ShammiKalsi
Fluorite | Level 6

Dear team,

 

We are creating password protected .pdf file by using SAS ODS. The size of pdf do vary, like some time pdf file having 2 pages , some time 3,4 and 5 pages.

I want to add images in the last page of password protected pdf file.

 

Kindly assist !!

 

Thanks in Advance..

 

Regards,

Sukhbir Singh

Mob: 95 82 85 38 56

4 REPLIES 4
SASJedi
SAS Super FREQ
Moved to the ODS forum, where is will likely get seen by folks with more experience in this area. Also, it would be helpful to explain what type of images you are adding to the PDF - are the images being generated by SAS (using SAS/Graph or the SG procedures) or are they some king of external image file located elsewhere on disk?
Check out my Jedi SAS Tricks for SAS Users
Cynthia_sas
SAS Super FREQ
Hi: If you use PROC REPORT, look at the example on page 11 of this paper https://support.sas.com/resources/papers/proceedings17/SAS0431-2017.pdf . I'm not sure how many images you have, but using COMPUTE AFTER would allow you to insert an image on the last page of your report. The example on page 11 shows both COMPUTE BEFORE (top of report) and COMPUTE AFTER (bottom of report/last page).
That might be one way to get started. But it does depend on what kind of image you want to insert and how they were created.

Cynthia
kalsi
Calcite | Level 5

Hi Cynthia,

 

Thanks for your response!!

 

I have applied in my code but it is not working. below is the sample code:

ods pdf text="~{newline 5}~S={JUST=C FONT_SIZE=12pt color=maroon }~{nbspace 75}* Account Summary *";
proc report data=temp1_0600
style(report)=[cellspacing=1 borderwidth=1 bordercolor=maroon textalign=c]
style(header)=[fontfamily="Abadi Extra Light" fontsize=1 Color=white textalign=c backgroundcolor=maroon]
style(column)=[fontfamily="Abadi Extra Light" fontsize=1 textalign=c ];
column OPENING_BALANCE TOT_DEBIT_AMT TOT_CREDIT_AMT CLOSING_BALANCE TRAN_COUNT;
define OPENING_BALANCE/'Opening Balance(INR)' display style(column)={cellwidth=1.5in just=right};
define TOT_DEBIT_AMT/'Total WithDrawals(INR)' display style(column)={cellwidth=1.7in just=right};
define TOT_CREDIT_AMT/'Total Deposits(INR)' display style(column)={cellwidth=1.5in just=right };
define CLOSING_BALANCE/'Closing Balance(INR)' display style(column)={cellwidth=1.5in just=right};
define TRAN_COUNT/'No. Of Transaction' display style(column)={cellwidth=1.5in just=right};
where ACC_NO="&ac";
/*compute after _page_ /style ={background=white preimage="/tmp/ippb1.jpg"};*/
/*endcomp;*/

 

Regards,

Sukhbir Singh

95 82 85 38 56

Cynthia_sas
SAS Super FREQ

Hi: If you look at my example, I used preimage in a different way. The COMPUTE block has to write SOMETHING -- preimage applies to the text that's being inserted into the COMPUTE block area. The text can be a text string, as I show in the paper. Or, the text can be a space. But the COMPUTE block area has to have something in it. That's why I have a LINE statement that writes a space into the COMPUTE area. This worked for me in PDF, as you can see below:

Cynthia_sas_0-1604415115534.png

 

  I had my image in the c:\temp\output folder and that's the folder where I wrote the PDF file too. Here's the code I ran:

options topmargin=.75in bottommargin=.75in rightmargin=.25in leftmargin=.25in;

*** assumes that image and file are stored in same &OUTPATH folder;
*** image stored in c:\temp\output folder;
%let outpath=c:\temp\output;

ods pdf(id=px1) file="&outpath\example_COMPUTE_AFTER_PAGE.pdf";

proc report data=sashelp.shoes spanrows;
  where region in ('Asia' 'Canada') and
        product in ('Boot' 'Sandal' 'Slipper');
  title 'Ex 2b) COMPUTE AFTER with image';
  column region product sales returns Profit inventory PctInv ;
  define region / group;
  define product / group;
  define profit / computed f=dollar14.;
  define pctinv / computed f=percent9.2;
  break after region/summarize;
  rbreak after / summarize;
  compute pctinv;
    profit = sum(sales.sum,-1*returns.sum);
    pctinv = sales.sum / inventory.sum;
  endcomp;
  compute after  / style={background=white preimage="&outpath\shoe_zoo.png"};
     line ' ';
  endcomp;
run;

ods pdf(id=px1) close;

My code uses SASHELP.SHOES so you should be able to run it. I put the shoe_zoo.png file inside a zip archive (since the forum would not allow a PNG file to be attached to the post). You'll have to unzip and store the image file in the same location. Without data no one can test your code, so this is something for you to try. As you see from my screen shot, the COMPUTE after with an image worked for me in PDF. It should work for you. If not, you may want to open a track with Tech Support.

 

Also, I would recommend that you experiment with both the COMPUTE AFTER, and the COMPUTE AFTER _PAGE_ to see which one works with your data to put the image on the last page.

 

Cynthia

 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 4 replies
  • 773 views
  • 0 likes
  • 4 in conversation