ODS PDF using the LASTPAGE inline style command generates PDF output with black pages


If the STYLE= option is used in the ODS PDF statement after the file is created, and the inline style command LASTPAGE is used on a title or footnote, PDF pages might display an all black background. In SAS® 9.3, the problem shows when a style is changed in the middle of the PDF document. In SAS® 9.4, the problem shows when the same style is applied in the middle of the document.

The workaround is to apply a single style on the ODS PDF file= statement or to remove the LASTPAGE command.

The sample code creates a two-page PDF file. The second page has an all black background. The workaround is to remove the toggled STYLE= specification, or to remove the LASTPAGE inline style command. 

title;
ods _all_ close;
options orientation = portrait ;
ods escapechar="^";
ods pdf file="file.pdf" notoc style=printer;

footnote1  j=r "Page ^{thispage} of ^{lastpage}";
proc report data=sashelp.class nowd;
run;

ods pdf style=sasdocprinter;
 /* problematic in SAS 9.4:
ods pdf style=printer;   */

proc report data=sashelp.class nowd;
run;

ods _all_ close;

/*  Workaround 1*/
ods pdf file="file1.pdf" notoc style=printer;
footnote1  j=r "Page ^{thispage} of ^{lastpage}";
proc report data=sashelp.class nowd;
run;

/*ods pdf style=sasdocprinter;*/
proc report data=sashelp.class  nowd   ;
run;

ods _all_ close;

/*  Workaround 2 */
ods pdf file="file2.pdf" notoc style=printer;
footnote1  j=r "Page ^{thispage} ";
proc report data=sashelp.class nowd;
run;

ods pdf style=sasdocprinter;

proc report data=sashelp.class  nowd   ;
run;

ods _all_ close;