The SAS Output Delivery System and reporting techniques

How to add Word document in ods pdf

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 109
Accepted Solution

How to add Word document in ods pdf

Hi Sas Experts,

 

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


Accepted Solutions
Solution
‎09-13-2016 08:59 AM
Esteemed Advisor
Posts: 6,635

Re: How to add Word document in ods pdf

- 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

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers

View solution in original post


All Replies
Esteemed Advisor
Esteemed Advisor
Posts: 7,190

Re: How to add Word document in ods pdf

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.

Grand Advisor
Posts: 17,299

Re: How to add Word document in ods pdf

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. 

Frequent Contributor
Posts: 109

Re: How to add Word document in ods pdf

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;

 

Frequent Contributor
Posts: 109

Re: How to add Word document in ods pdf

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;

Esteemed Advisor
Posts: 6,635

Re: How to add Word document in ods pdf

If your SAS process runs on a remote server, it can't see your local C: drive.

How is your SAS environment set up?

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Frequent Contributor
Posts: 109

Re: How to add Word document in ods pdf

Hi KurtBremser,

 

My SAS set up is on local server

Esteemed Advisor
Esteemed Advisor
Posts: 7,190

Re: How to add Word document in ods pdf

[ Edited ]

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

 

Valued Guide
Posts: 505

Re: How to add Word document in ods pdf

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

Frequent Contributor
Posts: 109

Re: How to add Word document in ods pdf

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

Solution
‎09-13-2016 08:59 AM
Esteemed Advisor
Posts: 6,635

Re: How to add Word document in ods pdf

- 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

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Esteemed Advisor
Esteemed Advisor
Posts: 7,190

Re: How to add Word document in ods pdf

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 @KurtBremser suggested).

Frequent Contributor
Posts: 109

Re: How to add Word document in ods pdf

Yes Thats now I got it.

 

Thank you

SAS Super FREQ
Posts: 8,716

Re: How to add Word document in ods pdf

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
Grand Advisor
Posts: 17,299

Re: How to add Word document in ods pdf

[ Edited ]

 

 

@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. 

☑ This topic is SOLVED.

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

Discussion stats
  • 22 replies
  • 843 views
  • 4 likes
  • 6 in conversation