Create a pdf with different styles for each page
I do this all the time because I need to combine
SAS ODF output with R/Python output
HAVE 2 pdfs with different left and right margins and
I need to combine them
%utl_pdflan100(
style=utl_pdflan1in
,rightmargin=.5in
,leftmargin=.5in
);
* create two PDFs;
ods pdf file="d:/pdf/part1.pdf" style=utl_pdflan1in;
proc print data=sashelp.class(obs=10);
run;quit;
ods pdf close;
%utl_pdflan100(
style=utl_pdflan2in
,rightmargin=1in
,leftmargin=1in
);
ods pdf file="d:/pdf/part2.pdf" style=utl_pdflan2in;
proc print data=sashelp.class(firstobs=9);
run;quit;
ods pdf close;
Solution
%utl_pdfcombine(file1=d:/pdf/part1.pdf,file2=d:/pdf/part2.pdf,file12=d:/pdf/part12.pdf);
GPL Ghostscript 9.19 (2016-03-23)
Copyright (C) 2016 Artifex Software, Inc. All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Processing pages 1 through 1.
Page 1
Processing pages 1 through 1.
Page 1
NOTE: 7 records were read from the infile CMD.
The minimum record length was 6.
The maximum record length was 70.
NOTE: DATA statement used (Total process time):
real time 0.60 seconds
user cpu time 0.03 seconds
system cpu time 0.00 seconds
memory 245.56k
OS Memory 16616.00k
Timestamp 12/12/2016 05:02:00 PM
Step Count 237 Switch Count 0
MPRINT(UTL_PDFCOMBINE): quit;
MPRINT(UTL_PDFCOMBINE): filename cmd clear;
NOTE: Fileref CMD has been deassigned.
MLOGIC(UTL_PDFCOMBINE): Ending execution.
/* T0100210 SAS/Ghostscript: Combining pdf files file1+file2 into file12
SAS/Ghostscript: Combining pdf files file1+file2 into file12
It is notable that the WPS Express edition does not support the
pdf destination.
If the two PDFs already exist you can append them in WPS.
As far as I can tell the two free versions of WPS support
command pipes.
inspired by
http://support.sas.com/kb/35/375.html
I could not see how to use the SAS solution above to work with
arbitrary PDFs.
Does not work with staic combinations of SAS PDFs, mixture SAS /non SAS or none SAS pdfs.
HAVE Two arbitrary pdfs
d:/pdf/part1.pdf
d:/pdf/part2.pdf
WANT append Part2.pdf to end of part1.pdf
d:/pdf/part12.pdf
Solution Working code
=====================
%utl_pdfcombine(file1=d:/pdf/part1.pdf,file2=d:/pdf/part2.pdf,file12=d:/pdf/part12.pdf);
Download ghostscript
http://www.ghostscript.com/download/
I copied the executable gswin64c.exe to my c:\pdf folder
C:\Program Files\gs\gs9.06\bin\gswin64c.exe to c:\pdf\gswin64c.exe
* combining pdf files;
%macro utl_pdfcombine(file1=&hspo01,file2=d:/hsp/pdf/hsp_page1.pdf,file12=&hspo02)
/des label="Combine ppdfs";
filename cmd pipe "d:\pdf\gswin64c.exe -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=&file12 -dBATCH &file1 &file2";
data _null_;
infile cmd;
input;
putlog _infile_;
;run;quit;
filename cmd clear;
%mend utl_pdfcombine;
%utl_pdfcombine(file1=d:/pdf/part1.pdf,file2=d:/pdf/part2.pdf,file12=d:/pdf/part12.pdf);
%Macro utl_pdflan100
(
style=utl_pdflan100
,frame=box
,TitleFont=14pt
,docfont=13pt
,fixedfont=12pt
,rules=ALL
,bottommargin=.25in
,topmargin=.25in
,rightmargin=.25in
,leftmargin=.25in
,cellheight=13pt
,cellpadding = 2pt
,cellspacing = .2pt
,borderwidth = .2pt
) / Des="SAS PDF Template for PDF";
ods path work.templat(update) sasuser.templat(update) sashelp.tmplmst(read);
Proc Template;
define style &Style;
parent=styles.rtf;
replace body from Document /
protectspecialchars=off
asis=on
bottommargin=&bottommargin
topmargin =&topmargin
rightmargin =&rightmargin
leftmargin =&leftmargin
;
replace color_list /
'link' = blue
'bgH' = _undef_
'fg' = black
'bg' = _undef_;
replace fonts /
'TitleFont2' = ("Arial, Helvetica, Helv",&titlefont,Bold)
'TitleFont' = ("Arial, Helvetica, Helv",&titlefont,Bold)
'HeadingFont' = ("Arial, Helvetica, Helv",&titlefont)
'HeadingEmphasisFont' = ("Arial, Helvetica, Helv",&titlefont,Italic)
'StrongFont' = ("Arial, Helvetica, Helv",&titlefont,Bold)
'EmphasisFont' = ("Arial, Helvetica, Helv",&titlefont,Italic)
'FixedFont' = ("Courier New, Courier",&fixedfont)
'FixedEmphasisFont' = ("Courier New, Courier",&fixedfont,Italic)
'FixedStrongFont' = ("Courier New, Courier",&fixedfont,Bold)
'FixedHeadingFont' = ("Courier New, Courier",&fixedfont,Bold)
'BatchFixedFont' = ("Courier New, Courier",&fixedfont)
'docFont' = ("Arial, Helvetica, Helv",&docfont)
'FootFont' = ("Arial, Helvetica, Helv", 9pt)
'StrongFootFont' = ("Arial, Helvetica, Helv",8pt,Bold)
'EmphasisFootFont' = ("Arial, Helvetica, Helv",8pt,Italic)
'FixedFootFont' = ("Courier New, Courier",8pt)
'FixedEmphasisFootFont'= ("Courier New, Courier",8pt,Italic)
'FixedStrongFootFont' = ("Courier New, Courier",7pt,Bold);
replace GraphFonts /
'GraphDataFont' = ("Arial, Helvetica, Helv",&fixedfont)
'GraphValueFont' = ("Arial, Helvetica, Helv",&fixedfont)
'GraphLabelFont' = ("Arial, Helvetica, Helv",&fixedfont,Bold)
'GraphFootnoteFont' = ("Arial, Helvetica, Helv",8pt)
'GraphTitleFont' = ("Arial, Helvetica, Helv",&titlefont,Bold)
'GraphAnnoFont' = ("Arial, Helvetica, Helv",&fixedfont)
'GraphUnicodeFont' = ("Arial, Helvetica, Helv",&fixedfont)
'GraphLabel2Font' = ("Arial, Helvetica, Helv",&fixedfont)
'GraphTitle1Font' = ("Arial, Helvetica, Helv",&fixedfont);
style Graph from Output/
outputwidth = 100% ;
style table from table /
outputwidth=100%
protectspecialchars=off
asis=on
background = colors('tablebg')
frame=&frame
rules=&rules
cellheight = &cellheight
cellpadding = &cellpadding
cellspacing = &cellspacing
bordercolor = colors('tableborder')
borderwidth = &borderwidth;
replace Footer from HeadersAndFooters
/ font = fonts('FootFont') just=left asis=on protectspecialchars=off ;
replace FooterFixed from Footer
/ font = fonts('FixedFootFont') just=left asis=on protectspecialchars=off;
replace FooterEmpty from Footer
/ font = fonts('FootFont') just=left asis=on protectspecialchars=off;
replace FooterEmphasis from Footer
/ font = fonts('EmphasisFootFont') just=left asis=on protectspecialchars=off;
replace FooterEmphasisFixed from FooterEmphasis
/ font = fonts('FixedEmphasisFootFont') just=left asis=on protectspecialchars=off;
replace FooterStrong from Footer
/ font = fonts('StrongFootFont') just=left asis=on protectspecialchars=off;
replace FooterStrongFixed from FooterStrong
/ font = fonts('FixedStrongFootFont') just=left asis=on protectspecialchars=off;
replace RowFooter from Footer
/ font = fonts('FootFont') asis=on protectspecialchars=off just=left;
replace RowFooterFixed from RowFooter
/ font = fonts('FixedFootFont') just=left asis=on protectspecialchars=off;
replace RowFooterEmpty from RowFooter
/ font = fonts('FootFont') just=left asis=on protectspecialchars=off;
replace RowFooterEmphasis from RowFooter
/ font = fonts('EmphasisFootFont') just=left asis=on protectspecialchars=off;
replace RowFooterEmphasisFixed from RowFooterEmphasis
/ font = fonts('FixedEmphasisFootFont') just=left asis=on protectspecialchars=off;
replace RowFooterStrong from RowFooter
/ font = fonts('StrongFootFont') just=left asis=on protectspecialchars=off;
replace RowFooterStrongFixed from RowFooterStrong
/ font = fonts('FixedStrongFootFont') just=left asis=on protectspecialchars=off;
replace SystemFooter from TitlesAndFooters / asis=on
protectspecialchars=off just=left;
end;
run;
quit;
%Mend utl_pdflan100;
... View more