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

Hi Sas Experts,

 

Is there is any way to add word documents as my coverpage in ods pdf. Please help.

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

- display your coverpage pdf in a pdf viewer

- use your favorite imaging tool (I recommend irfanview) to do a screenshot of the pdf

- save as .jpg

- use that as preimage

View solution in original post

22 REPLIES 22
RW9
Diamond | Level 26 RW9
Diamond | Level 26

No, not directly.  The reason being is that the Word document needs to be converted to a PDF - requiring licenses for the both of them, hence its outside the remit of a SAS topic.  You could of course script (VB/VBA, PDF javascript) a process where the PDF output is combined with the output of printing to PDF from Word.

Reeza
Super User

Word can print or save to PDF

 

If you have Adobe professional you can append the PDF files. 

 

You can use SAS to manage these tasks but the activity does occur elsewhere. 

sanjay1
Obsidian | Level 7

Hi Reeza,

As you suggested i have converted the word to pdf and used in my progrm. But am getting the error. Please help

Below is the error:

Error:  Unable to load image C:\temp\test.pdf; default image will be used instead

 

Following is my code

ods pdf file='path.pdf' notoc startpage=no color=full style=colorramp;

ods pdf text='^{style[preimage="C:\temp\test.pdf"}';

ods pdf startpage=now;

 

goptions hsize=3.99 in vsize=4.2 in;
proc print data=sashelp.class;

goptions horigin=0 in vorigin=4 in;

run;

 

proc means data=sashelp.class;

goptions horigin=4.25;

var height;
run;

ods pdf close;

 

sanjay1
Obsidian | Level 7

Hi RW9,

As you suggested i have converted the word to pdf and used in my progrm. But am getting the error. Please help me

Below is the error:

Error:  Unable to load image C:\temp\test.pdf; default image will be used instead

 

Following is my code

ods pdf file='path.pdf' notoc startpage=no color=full style=colorramp;

ods pdf text='^{style[preimage="C:\temp\test.pdf"}';

ods pdf startpage=now;

 

goptions hsize=3.99 in vsize=4.2 in;
proc print data=sashelp.class;

goptions horigin=0 in vorigin=4 in;

run;

 

proc means data=sashelp.class;

goptions horigin=4.25;

var height;
run;

ods pdf close;

sanjay1
Obsidian | Level 7

Hi KurtBremser,

 

My SAS set up is on local server

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Edit: Also note you have a typo in your code:

ods pdf text='^{style[preimage="C:\temp\test.pdf"}';

There is no closing ]

 

Sorry, that is not what I suggest.  Yes, the Word file needs to be sent to PDF, using a method there - e.g print to file from Word.  But the combination still does not happen in SAS.  Adobe has its own Combine PDF feature that you would use (assuming you have that software).  The option in SAS preimage is for adding a picture to the document, not for combining PDF's.  

As I mention above, this is using PDF/Word technology, and is not for SAS.  Search google for "vb combine pdf files", there are many examples.  The flow would look something like:

SAS                         Word
Create PDF         Create PDF


                   PDF
            Combine PDFs

 

rogerjdeangelis
Barite | Level 11
For non-programmers you can mouse surf a solution using libreoffice.
LibreOffice can also convert MS Office docs to PDF and append them.

You only need gswin64c.exe from open source ghostscript.


HAVE

   d:/pdf/class.pdf
   d:/pdf/cars.pdf

WANT APPEND CARS.PDF TO CLASS.PDF

   d:/pdf/classcars.pdf


SOLUTION

ods pdf file="d:/pdf/class.pdf";
proc print data=sashelp.class;
run;quit;
ods pdf close;


ods pdf file="d:/pdf/cars.pdf";
proc print data=sashelp.cars(obs=20);
run;quit;
ods pdf close;


x "cd d:\pdf";
x "C:\Progra~1\gs\gs9.19\bin\gswin64c.exe -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=classcars.pdf -dBATCH class.pdf  cars.pdf";



11    ods pdf file="d:/pdf/class.pdf";
NOTE: Writing ODS PDF output to DISK destination "d:\pdf\class.pdf", printer "PDF".
12    proc print data=sashelp.class;
13    run;

NOTE: There were 19 observations read from the data set SASHELP.CLASS.
NOTE: PROCEDURE PRINT used (Total process time):
      real time           0.05 seconds
      user cpu time       0.00 seconds
      system cpu time     0.03 seconds
      memory              656.25k
      OS Memory           13796.00k
      Timestamp           09/13/2016 05:08:00 AM
      Step Count                        10  Switch Count  0


13  !     quit;
14    ods pdf close;
NOTE: ODS PDF printed 1 page to d:\pdf\class.pdf.
15    ods pdf file="d:/pdf/cars.pdf";
NOTE: Writing ODS PDF output to DISK destination "d:\pdf\cars.pdf", printer "PDF".
16    proc print data=sashelp.cars(obs=20);
17    run;

NOTE: There were 20 observations read from the data set SASHELP.CARS.
NOTE: PROCEDURE PRINT used (Total process time):
      real time           0.07 seconds
      user cpu time       0.07 seconds
      system cpu time     0.00 seconds
      memory              1186.53k
      OS Memory           14564.00k
      Timestamp           09/13/2016 05:08:01 AM
      Step Count                        11  Switch Count  0


17  !     quit;
18    ods pdf close;
NOTE: ODS PDF printed 2 pages to d:\pdf\cars.pdf.
19    x "cd d:\pdf"
19  !              ;
20    x "C:\Progra~1\gs\gs9.19\bin\gswin64c.exe -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=classcars.pdf -dBATCH class.pdf  cars.pdf"
20  !                                                                                                       ;

sanjay1
Obsidian | Level 7

Hi ,

Thank you very much for your help, but I dont have multiple pdfs , I have one word doc which is converted to pdf.

I want to use this pdf as my cover page, and rest of the pdfs I will generate by using sas.

 

Basically It looks like the below code,  in the ods pdf text statement am referring to the coverpage pdf.

 

ods pdf file='path.pdf' notoc startpage=no color=full style=colorramp;

ods pdf text='^{style[preimage="C:\temp\test.pdf"}';

ods pdf startpage=now;

 

goptions hsize=3.99 in vsize=4.2 in;
proc print data=sashelp.class;

goptions horigin=0 in vorigin=4 in;

run;

 

proc means data=sashelp.class;

goptions horigin=4.25;

var height;
run;

ods pdf close;

 

Below is the error:

Error:  Unable to load image C:\temp\test.pdf; default image will be used instead

Kurt_Bremser
Super User

- display your coverpage pdf in a pdf viewer

- use your favorite imaging tool (I recommend irfanview) to do a screenshot of the pdf

- save as .jpg

- use that as preimage

RW9
Diamond | Level 26 RW9
Diamond | Level 26

I think your missing the fundamental point here.  PDF is not a SAS technology, it is owned by a separate company - Adobe.  To convert information from other file types to PDF requires a converter.  There is a convertor built into Word so you can print Word files to PDF.  There is a PDF creator built into SAS ODS (the bit that creates reports).  Neither of these provide "merging" functionality, you need third party software to do this, be it LibreOffice, Adobe etc.  You cannot do it in SAS (unless you want to convert it to an image as @Kurt_Bremser suggested).

sanjay1
Obsidian | Level 7

Yes Thats now I got it.

 

Thank you

Cynthia_sas
SAS Super FREQ
Looks like you posted this same question in a different forum. There was an answer posted there, too:
https://communities.sas.com/t5/SAS-GRAPH-and-ODS-Graphics/How-to-list-and-use-all-the-colors-in-sas-...

cynthia
Reeza
Super User

 

 

@sanjay1

Do you have Adobe Pro? If so, see the methods used here:

http://analytics.ncsu.edu/sesug/2011/BB15.Welch.pdf

 

You have multiple PDF files, the first page plus the SAS output. 

 

You coukd try to create the first page as a PNG image and use the insert method your attempting. 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 22 replies
  • 2595 views
  • 4 likes
  • 6 in conversation