54
Paper SAS038-2014
PDF vs. HTML: Can't We All Just Get Along?
Scott Huntley, Cynthia Zender, SAS Institute
ABSTRACT
Have you ever asked, “Why doesn't my PDF output look just like my HTML output?” This paper explains the power
and differences of each destination. You will learn how each destination works and understand why the output looks
the way it does. Learn tips and tricks for how to modify your SAS
®
code to make each destination look more like the
other. The tips span from beginner to advanced in all areas of reporting. Each destination is like a superhero, helping
you transform your reports to meet all your needs. Learn how to use each ODS destination to the fullest extent of its
powers.
INTRODUCTION
Superheroes are all different. Some superheroes have science and technology on their side (Ironman, Batman,
Aquaman); some have super powers because they are from another planet or time (Thor, Superman); while others
became accidental superheroes (Hulk, Spiderman). Just as superheroes are able to do marvelous things, in different
ways, based on their abilities, each ODS destination has a set of abilities and superpowers based on the underlying
architecture and purpose of the destination. This paper addresses two ODS destinations: PDF and HTML.
CREATION STORY
Every superhero has a creation story. PDF and HTML have creation stories too. HTML was probably the first ODS
destination. With SAS version 7, ODS HTML and ODS RTF were initially introduced along with the ODS PRINTER
destination. The PDF destination was not production until SAS 8.2. The underlying architecture of ODS dictated that
style information (colors, fonts, borders, and so on) appropriate to each destination would be sent to each destination
(using an ODS style template) along with the data from the SAS process or procedure. Then ODS would write
instructions that could be rendered by a 3
rd
party application.
ODS HTML initially created HTML 3.2 compliant HTML tags or elements, in SAS 7. The rendering application for
HTML output was a web browser (although Microsoft Word and Microsoft Excel have been able to open HTML files
ever since Office 97). Initially, with ODS the Printer family consisted of ODS PRINT, ODS PS and ODS PCL. When
you wanted a PDF file, initially, you created a PostScript file and needed to distill it to PDF form. In SAS 8.2, the ODS
PDF destination became production.
Right from the beginning the underlying assumptions of HTML and PDF were different. HTML was designed for
screen viewing. PDF could be viewed on the screen but it creates output that is in a format that is readable by Adobe
or other 3
rd
party products that consume PDF. Basically it creates output that is printable. What you see in a viewer
like Acrobat will print out with the same appearance. Another nice thing about the PDF destination was that it was a
good way to deliver output that would be hard to change without using fancy Adobe editing tools. HTML was difficult
to change, too, but mostly because not everyone knew HTML tags and instructions. But, HTML is not a “paged”
destination, so things like page numbers and page breaks and printing control really work better in PDF than in HTML
(where they are not used at all). The rendering browser controls how an HTML file will be printed, and to some extent
you might be able to impact that printing using CSS @media instructions.
WHAT IS MEASURED OUTPUT?
The underlying architecture of PDF versus HTML has far-reaching impact on the output, beyond the concept of which
application renders the output. Now we can look at a concrete example. In the code below, two separate reports are
created, taking all the defaults and changing orientation. Other changes are minor. HTML uses the default
HTMLBLUE style template and PDF uses the PRINTER style. By default PDF also includes a bookmark area, but
that feature is easily turned off with the NOTOC option. All the reports use SASHELP.CARS, which is delivered with
Base SAS, so it should be easy to replicate these results.
options orientation=portrait topmargin=.25in bottommargin=.25in
leftmargin=.25in rightmargin=.25in number;
ods html file='c:\temp\default1.html' style=htmlblue;
1