/* * Fix PostScript for PDF * * (c) 2003 SAS Institute Inc. * * This macro will fix up the PDFMARKed output from SAS v8.2 and * up to * a) Allow you to change the color of links, or to get rid of the * boxes entirely, and * b) Make the distilled output open on the first page rather than * the last page. * * In order to "distill" PostScript into PDF, you must have a third- * party project, such as Adobe Acrobat Distiller (sold as part of * the Adobe Acrobat product for Windows; or ps2pdf, which is part * of the ghostscript programs for Unix systems (including Linux). * * Usage * * fix_pdfmark(tempfile, filename, color=, border=); * tempfile Is the name of the temporary file supplied to * ODS PRINTER or ODS PS. * filename Is the name of the final postscript file - the * one that you will then distill to produce the * PDF output. * color= Optional. If present, the border color of * existing links will be changed to this. * The color is of the form R G B in a scale from 0 to 1; * thus, the default color is ".00 .00 1.0". * Since LINKCOLOR= controls this already I'm not sure * why it's necessary, but it was requested so what the * heck. * border= Specify the border (size) for links. * If is of the form bx by c [dash], where bx and by * are corner radii, and c is the width of the border, * and [d] is an optional dash array. * The default border from SAS is "2 2 2". * Use 0 0 0 to turn this off. * * Usage: * * ods ps pdfmark file=".tmp" . . .; * : * [sas code] * : * ods ps close; * * %fix_pdfmark(".tmp", ".ps"); * * PC: Easiest is to set up a "watched folder" with distiller and simply * specify as the folder; e.g., C:\watched\folder\myfile.ps * * Unix: x ps2pdf myfile.ps; * * *********************** * * Note that you can combine the various "fix-up" macros; e.g., this uses * all of them: * * %include fda; * %include fixmark; * %include pageof; * * %start_pageof; * ods ps pdfmark file="myfile.a"; * : * [sas code] * ods ps close; * %end_pageof("myfile.a", "myfile.b"); * %make_compliant("myfile.b", "myfile.c"); * %fix_pdfmark("myfile.c", "myfile.ps"); * * then distill "myfile.ps" into "myfile.pdf". */ %let had_color = no; %let had_border = no; ods listing close; %macro fix_pdfmark(tempfile, permfile, color=, border=); %let replace_color = 0; %let replace_border = 0; %if _&color ^= _ %then %do; %let color_line = "[&color]"; %let replace_color = 1; %end; %if _&border ^= _ %then %do; %let border_line = "[&border]"; %let replace_border = 1; %end; data _null_; infile &tempfile lrecl=25000 pad; file &permfile lrecl=25000; length line $25000; length had_color $10 had_border $10; input line $char.; place = index(line, "/UseOutlines"); if place = 1 then line = "/UseOutlines /Page 1"; %if &replace_color %then %do; had_color = symget('had_color'); if (had_color = 'yes') then do; line = &color_line; call symput('had_color', 'no'); end; place = index(line, "/Color"); if (place = 1) then call symput('had_color', 'yes'); %end; %if &replace_border %then %do; had_border = symget('had_border'); if (had_border = 'yes') then do; if line = '[' then line = &border_line; else if line = ']' then do; line = ' '; call symput('had_border', 'no'); end; else line = ' '; end; place = index(line, "/Border"); if (place = 1) then call symput('had_border', 'yes'); %end; put line; run; %mend;