BookmarkSubscribeRSS Feed
stan
Quartz | Level 8

During multiple file processing (many thanks to nice paper by Kevin McGowan and Matt Reich)

SAS reads 8 '.txt' files and produces 8 '.pdf' files to the same directory.

How to write 8 '.pdf' files into one with correct pagination?

I name the '.pdf' files in a 'DDMMMYY-HH-MM-SS-mS' fashion according to the first basic approach

described in the paper with the

ODS PDF FILE = "&my_folder.\%sysfunc(translate(%sysfunc(datetime(),datetime20.3),--,.:))&MyExtt"

statement. I tried to use the following:

ODS PDF FILE = "&my_folder.\PDF_FILES_COMBINED&MyExtt"

but the ERROR alike '.../PDF_FILES_COMBINED.pdf doesn't exist' appears.

How to solve the task ?

Thank you.

6 REPLIES 6
Cynthia_sas
SAS Super FREQ

Hi:

  Every PDF file, whether made by SAS or made by some other method has specific "open" and "close" syntax. So the issue is that once SAS creates a separate PDF file, you cannot use SAS to combine the separate PDF files. You would need an Adobe product or some 3rd party PDF "combiner" app to do that, post processing.

  So the challenge is this...you have this now, where I assume that your macro program is reading multiple TXT files and creating a unique ODS "sandwich" for each TXT file (like this, without the fancy names):

ods pdf file='file1.pdf';

...code 1...;

ods pdf file close;

ods pdf file='file2.pdf';

...code 2...;

ods pdf close;

And, instead, what you need to do is this -- go ahead and read all 8 TXT files, but change your ODS PDF invocation, so that all 8 proc prints or proc "whatevers" are inside just 1 ODS PDF sandwich:

ods pdf file='allfiles.pdf';

...code 1...;

     

...code 2...;

ods pdf close;

  You cannot (easily) combine the separate PDF files afte SAS creates them. I have heard of folks making PostScript files, then reading the PostScript file with a program and then stripping out the "open/close" syntax and then making a PDF by writing all the "stripped" files back out, but it is a HUGE effort and far easier to alter your ODS "sandwich" or to get an Adobe product to do the combining after the fact.

cynthia

jakarman
Barite | Level 11

Instead of putting out PDF immediate you could use  SAS(R) 9.4 Output Delivery System: User's Guide (Proc Document)
First saving it in a SAS environment and than creating the output what you want

---->-- ja karman --<-----
cathyhill
Calcite | Level 5

"So the issue is that once SAS creates a separate PDF file, you cannot use SAS to combine the separate PDF files. You would need an Adobe product or some 3rd party PDF "combiner" app to do that, post PDF processing." Is this true? I thought I can do the basic PDF document processing works within SAS without using Aodobe products. A little disappointing.

Cynthia_sas
SAS Super FREQ

Hi:

  You can absolutely make 1 PDF file from multiple SAS procedures like this:

ODS PDF file="all_3_procedures.pdf";

** procedure 1;

** procedure 2;

** procedure 3;

ODS PDF CLOSE;

But this was not the original question as I understood it. In the original question, the original poster said that 8 txt files had been converted to 8 separate PDF files and that the new requirement was to combine the 8 separate PDF files into 1 "new" PDF file. This is different than the "sandwich" code I showed above. So when you said "I thought I can do the basic PDF document processing works within SAS without using Adobe products." The "basic" processing is what I showed above...a single ODS PDF "sandwich" that captures your procedure or multiple procedure output to create 1 PDF file. This is the basic processing. More advanced processing is to save your procedure output in an ODS DOCUMENT store and then rearrange and/or replay that output from ODS DOCUMENT format to PDF output using ODS DOCUMENT/PROC DOCUMENT. This is also possible.

If you have multiple, already existing PDF files....whether created by SAS or not, let's call them myfile1.pdf, myfile2.pdf and myfile3.pdf, then that is not "basic" ODS processing. As far as I know, Adobe has specific "start of file" and "end of file" information embedded in each PDF file when it is created. So, the only way to combine them into a single "new" PDF file is to use an Adobe product or a 3rd party software program that combines existing PDF files.

cynthia

BenthamLEE
Calcite | Level 5

After or before multiple pdf pages processing, you can combine multiple pdf documents, like you said, 8 pdf files, or even more into one new pdf document by using a pdf merger, that is to say, you only need to implement a pdf document merging tool add-on, then you can integrate this pdf merger into your visual basic or c sharp application to merge multiple pdf files into one. And I am a programmer using visual basic a lot, so, I would like to share my codes on pdf merging to you, you are allowed to copy and make some modification of them.

Public Sub CombineDocumentsToStream(s As Stream, docList As List(Of BaseDocument))

PDFDocument.Combine(docList, s)

End Sub

Tag: pdf processing, documents combining

umashankersaini
Quartz | Level 8

Hi,

Try to use Nitro PDF professional software for any operation with pdf (combining, deleting pages, spliting, editing....).

Any help related to Nitro, please let me know.

Regards

Uma Shanker Saini

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
  • 6 replies
  • 5052 views
  • 7 likes
  • 6 in conversation