Desktop productivity for business analysts and programmers

Page breaks in HTML output

Frequent Contributor
Posts: 97

Page breaks in HTML output

Does HTML reports recognise page breaks, if yes then how to specify them.
Posts: 9,428

Re: Page breaks in HTML output

Page breaks are not part of the standard HTML specification by the W3C.ORG group. However, there is some support for page-breaks when printing in the CSS 2 specification, as described here: , ,
and, simpler, here:

Remember, however, that not all browsers support the CSS 2 specification. So, even if you use the technique shown on the above web page, it is only a SUGGESTION for the browser -- the browser may ignore the SUGGESTION if it is not fully CSS 2 compliant.

In fact ODS supports this method. In the standard style template (styles.default) that is used with ODS HTML, SAS puts a CSS instruction for the places where it would normally insert a "page break" (which is visible as a horizontal rule):
'PageBreakLine' =
"<p style=""page-break-after: always;""><br></p><hr size=""3"">"

Generally this horizontal rule appears between each procedure in your output or between BY groups. However, if you have a BY group of 200 obs, there would be no "internal" horizontal rule or page-break CSS instruction placement. That's because HTML was supposed to be leading us all to the paperless office and there are no page breaks in the paperless office. So you probably do NOT want to mess with the
page-break-after: always CSS instruction.

There is another HTML method (instead of trying to put page breaks into HTML) and that is specifying an alternate file to print. This method requires IE 4 or higher, but in this method, you can have a LINK tag like this:
<link rel=alternate media=print href="printversion.pdf">
<link rel=alternate media=print href="printversion.rtf">
There is an ODS example here:

However, when I try to use the LINK tag method, as described above, I only get a single blank page that prints and it has the name of the alternate file at the bottom of the page. So clearly, my browser (IE6) doesn't like either the LINK tag or the relative reference that I used. I'm not sure which.

Another thing to consider would be to explicitly put a LINK on the page (either using ODS HTML TEXT= or using a TITLE statement with a hyperlink) and the link would explicitly load a "printer-friendly" copy of the report. This is illustrated at the bottom of the posting.


So the general scenario would be:
** Make a print version (PDF or RTF) of the file using ODS;
ods pdf file='c:\temp\printversion.pdf'; code with page numbers and possible PDF options...
ods pdf close;

** Option 1 -- explicitly code an ANCHOR tag using ODS HTML TEXT= ;

ods html path='c:\temp' (url=none)
file='htmlversion1.html' style=sasweb;

ods html text='<div><a href="printversion.pdf">Printer Friendly Copy (from TEXT=)</a></div>';

... report code ...

ods html close;

** Option 2: Use LINK= in the TITLE statement;

ods html path='c:\temp' (url=none)
file='htmlversion2.html' style=sasweb;

title j=l h=12pt link='printversion.pdf' "Printer Friendly Version of Report";

... report code ...

ods html close;

Ask a Question
Discussion stats
  • 1 reply
  • 2 in conversation