From PostScript To PDF

There was a time when each and every printer and typesetter had its own quirky language. If you had a wordprocessor from a particular company, it worked with the printers from that company, and that was it. That was the situation in the 1970s when some engineers at Xerox Parc — a great place for innovation but a spotty track record for commercialization — realized there should be a better answer.

That answer would be Interpress, a language for controlling Xerox laser printers. Keep in mind that in 1980, a laser printer could run anywhere from $10,000 to $100,000 and was a serious investment. John Warnock and his boss, Chuck Geschke, tried for two years to commercialize Interpress. They failed.

So the two formed a company: Adobe. You’ve heard of them? They started out with the idea of making laser printers, but eventually realized it would be a better idea to sell technology into other people’s laser printers and that’s where we get PostScript.

Early PostScript and the Birth of Desktop Publishing

PostScript is very much like Forth, with words made specifically for page layout and laser printing. There were several key selling points that made the system successful.

First, you could easily obtain the specifications if you wanted to write a printer driver. Apple decided to use it on their LaserWriter. Of course, that meant the printer had a more powerful computer in it than most of the Macs it connected to, but for $7,000 maybe that’s expected.

Second, any printer maker could license PostScript for use in their device. Why spend a lot of money making your own when you could just buy PostScript off the shelf?

Finally, PostScript allowed device independence. If you took a PostScript file and sent it to a 300 DPI laser printer, you got nice output. If you sent it to a 2400 DPI typesetter, you got even nicer output. This was a big draw since a rasterized image was either going to look bad on high-resolution devices or have a huge file system in an era where huge files were painful to deal with. Even a page at 300 DPI is fairly large.

If you bought a Mac and a LaserWriter you only needed one other thing: software. But since the PostScript spec was freely available, software was possible. A company named Aldus came out with PageMaker and invented the category of desktop publishing. Adding fuel to the fire, giant Linotype came out with a typesetting machine that accepted PostScript, so you could go from a computer screen to proofs to a finished print job with one file.

If you weren’t alive — or too young to pay attention — during this time, you may not realize what a big deal this was. Prior to the desktop publishing revolution, computer output was terrible. You might mock something up in a text file and print it on a daisy wheel printer, but eventually, someone had to make something that was “camera-ready” to make real printing plates. The kind of things you can do in a minute in any word processor today took a ton of skilled labor back in those days.

Take Two

Of course, you have to innovate. Adobe did try to prompt Display PostScript in the late 1980s as a way to drive screens. The NeXT used this system. It was smart, but a bit slow for the hardware of the day. Also, Adobe wanted licensing fees, which had worked well for printers, but there were cheaper alternatives available for displays by the time Display PostScript arrived.

In 1991, Adobe released PostScript Level 2 — making the old PostScript into “Level 1” retroactively. It had all the improvements you would expect in a second version. It was faster and crashed less. It had better support for things like color separation and handling compressed images. It also worked better with oddball and custom fonts, and the printer could cache fonts and graphics.

Remember how releasing the spec helped the original PostScript? For Level 2, releasing it early caused a problem. Competitors started releasing features for Level 2 before Adobe. Oops.

They finally released PostScript 3. (And dropped the “Level”.) This allowed for 12-bit colors instead of 8-bit. It also supported PDF files.

PDF?

While PostScript is a language for controlling a printer, PDF is set up as a page description language. It focuses on what the page looks like and not how to create the page. Of course, this is somewhat semantics. You can think of a PostScript file as a program that drives a Raster Image Processor (RIP) to draw a page. You can think of a PDF as somewhat akin to a compiled version of that program that describes what the program would do.

Up to PDF 1.4, released in 2001, everything you could do in a PDF file could be done in PostScript. But with PDF 1.4 there were some new things that PostScript didn’t have. In particular, PDFs support layers and transparency. Today, PDF rules the roost and PostScript is largely static and fading.

What’s Inside?

Like we said, a PostScript file is a lot like a Forth program. There’s a comment at the front (%!PS-Adobe-3.0) that tells you it is a PostScript file and the level. Then there’s a prolog that defines functions and fonts. The body section uses words like moveto, lineto, and so on to build up a path that can be stroked, filled, or clipped. You can also do loops and conditionals — PostScript is Turing-complete. A trailer appears at the end of each page and usually has a command to render the page (showpage), which may start a new page.

A simple PostScript file running in GhostScript

A PDF file has a similar structure with a %PDF-1.7 comment. The body contains objects that can refer to pages, dictionaries, references, and image or font streams. There is also a cross-reference table to help find the objects and a trailer that points to the root object.  That object brings in other objects to form the entire document. There’s no real code execution in a basic PDF file.

If you want to play with PostScript, there’s a good chance your printer might support it. If not, your printer drivers might. However, you can also grab a copy of GhostScript and write PostScript programs all day. Use GSView to render them on the screen or print them to any printer you can connect to. You can even create PDF files using the tools.

For example, try this:


%!PS
% Draw square
100 100 moveto
100 0 rlineto
0 100 rlineto
-100 0 rlineto
closepath
stroke

% Draw circle
150 150 50 0 360 arc
stroke

% Draw text "Hackaday" centered in the circle
/Times-Roman findfont 12 scalefont setfont % Choose font and size
(Hackaday) dup stringwidth pop 2 div % Calculate half text width
150 exch sub % X = center - half width
150 % Y = vertical center
moveto
(Hackaday) show

showpage

If you want to hack on the code or write your own, here’s the documentation. Think it isn’t really a programming language? [Nicolas] would disagree.

24 thoughts on “From PostScript To PDF

  1. “Finally, PostScript allowed device independence.”
    So did HPGL, the ancient plotter language.
    It was the predecessor to PDF in several ways, I think.

    Back in the 80s, you converted your document by printing into a file.
    The selected printer driver (say HP LaserJet for HPGL/PCL) determined the output format.
    That’s not very different to using modern PDF “virtual printers”.

    I do always do remember PostScript being those fat files that can’t be open properly on DOS or Windows 3.x! 😂🥲
    Unix believers may have different memories, of course.

    1. HPGL was never as device independent as one would like, unfortunately. I made a lot of gravy writing HGPL drivers and translators, back in the day. Things like minor punctuation differences would be required moving from one device to another, then the hardware specifics, like available pens, would lead to different behaviours on different devices.

      1. Agreed. Though it predated PostScript 1 by ~7 years, also.
        That’s why I felt I should mention it, there was no reference in the article.

        In addition PostScript always had smelled rather academic/unix-like,
        home computer users perhaps never really noticed it, except for their printer manual that listed “PostScript ” compatibility.

        Fast forward, into early 90s, early versions of Adobe Acrobat PDF Reader had no use for *.PS files, either.
        That’s when users on Windows 3.x or OS/2 slowly learned about PDF.
        It was the file format being used for digitized manuals on their driver CDs.

        In real life, though, they rather continued to exchange MS Works documents, Write, WordPad (RTF)
        and Word files, plain text and bitmap (PCX/BMP/GIF/TGA, TIFF files for fax).

        According to my gut feeling, I think PCL3/PCL3+ perhaps was what most DOS programs had used in late 80s/early 90s,
        thanks to the popular HP LaserJet+ and HP DeskJet 500 (and its color cousin).
        DXF was an option, too, at least for CAD like applications.

        PCL printers in turn, often also understood HPGL.
        According to Wikipedia, there also was HP-GL/2 (?) that fusioned with later PCL versions.

        I perhaps should also add that all three share some similarities.
        Like “the good, the bad and the ugly” so to say. Just who’s who? 🤔

        Comparision PostScript vs HPGL, for the youngsters:
        https://transera.com/help/postscriptdriver_print.htm

  2. Before Sun Microsystems’s James Gosling created Java, he made a thing called NeWS, which was an extended implementation of PostScript in which you could write GUI programs. It was baked into some of the early (Solaris 1) releases, and included a demo application called “pizzatool”, which was way ahead of its time.

    https://en.wikipedia.org/wiki/NeWS

    https://donhopkins.medium.com/the-story-of-sun-microsystems-pizzatool-2a7992b4c797

    NeWS was slow and clunky, mostly because it was an interpreted language (vs. compiled).

  3. Back when I was doing the code for my thesis, we had available (R1 school) a lot of computing power, including from Maynard, MA, some Wangs, and a big one painted blue. The blue machine was a timeshare in the heavy iron way, charging per seond, or hundredth thereof, for CPU, memory usage, storage, and all. The machines from Maynard were ok, but still multiuser and not top performers. They weren’t charged, though, in department. Then along came the printer. It ran Postscript. It cost nothing but $0.10/page, no matter if it was a single line or a sheet painted black, computed as fast as the data could go to the print engine, or 2hours of processing before the page came out.

    In the end I had written, or borrowed from others, a full 3D vector library, a quarternion library, a tensor library, and some special functions, and the printer did all of the computation for my thesis, for the price of a few sheets of paper.

    I don’t want to know what it would have cost on the blue machine….

    1. A couple of decades ago, alone in the building at night, I sent a certain fractal-drawing PostScript file to the printer then of course promptly forgot about it.
      When about two hours later the printer came to and spat the results out I’m pretty sure I had a minor heart attack.

      1. In the mid 90’s, I bought my own KX-P5400 (panasonic LED bar, postscript printer). M first non-impact unit. Reasonable price, reasonable paper path for the time, so I could use heavy stock. Only 300DPI and slow, but it did the job at home.

        I ran a few hardcore fractal sets on it, and had similar experiences.

        My thesis code took longer in it than it did on the original unit, despite the Panasonic being Level2 postscript and many years later. I guess that is why it was so inexpensive.

  4. On macOS, Preview used to support automatic ps to pdf conversion, but this was dropped around macOS Ventura. I installed Ghostscript to deal with that: brew install ghostscript . Make sure you install the version for the right architecture, it’ll work if you get it wrong, it’ll just be slow. Ghostscript includes ps2pdf, which will then do the job (it worked on the example above).

  5. The late great Don Lancaster did not need graphics software. He created the images in his books using PostScript code embedded (Hidden) in AppleWriter. AppleWriter allowed including various macros and languages to be hidden from printable output and be executed to produce everything from formatting to creating graphics. He did everything from charts and tables to rendering a piano, etc. Like Neo seeing the world in the green code waterfall.

    One odd thing is the nature of PostScript. Both PARC and later Adobe are in walking distance of an HP building where the Silicon Valley Forth Interest Group (SVFIG) met on Saturdays. PostScript is strikingly like Forth with name changes. For example, SWAP is EXCHANGE in ps. Plus to meet the scale independent demands for printing, a floating point data type. Yet Warnock claimed to have never heard of Forth. In fairness I have known a couple people who created their own advanced interpreter on 6502 boards and we shocked when they saw Forth. They had nearly identical elements – except the compiler feature that really sets Forth apart.

  6. Yay! Back in the 80s, PS was amazing. It meant actual quality printing. Though to be fair, in the 80s having any printer at home was amazing.

    Even in the 90s most people who had printers had bubblejets if they were lucky, 9-pin DMs if not. Both very low res and erratic quality with line artefacts, smudges, and blurs. Lasers with PS had amazing crisp readable text.

    Also printers understood PS fonts – they could be pre-installed on the printer, or downloaded into the printer with the job, and that meant smaller and much faster print jobs, especially when it came to documents with hundreds of pages.

    That and the smell of ozone are my childhood memories of growing up with a laser printer in the house.

    1. “Also printers understood PS fonts – they could be pre-installed on the printer, or downloaded into the printer with the job,
      and that meant smaller and much faster print jobs, especially when it came to documents with hundreds of pages.”

      This is a valid point.: Laser printers usually were smarter or had more processing power than anything else.

      For example, laser printers often did support up to PCL5 (in the 90s),
      while ink printers were limited to older PCL3 from mid-80s (includes plus, color variant etc).

      The early HP LaserJet was driven by a Motorola 68000 and did support optional font cassettes, too.
      And something like an PostScript emulation cartridge (such as Pacific Page PE, LaserJet IIp to IIIp).

      Some versions of HD DeskJet 500 later had an optional Epson emulation cartridge, due to both being overly popular.
      The DeskWriter 500 was the Apple Macintosh equivalent, by the way, supporting AppleTalk (I think).

  7. I recall watching the Linotype laser machines at work. They also included a regular laser printer for proof printing it. This was a shop which did advertising copy. It outgrew from a Union shop which did first hot metal typography and then photo typesetting. Finally moving to the laser before it became a non Union shop doing both. (Photo and laser.) Fun times. Let’s just say it ran as a photo (Union shop) using the PDP-8 before transitioning to the DG families.

Leave a Reply to Julian SkidmoreCancel reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.