Cocoa apps: File -> Print -> Save As PDF. Probably scriptable with AppleScript/osascript, though I haven't tried.
This should let you print to a PDF exactly as you would print to a real printer. The only difference is that you end up with a PDF file instead of a physical printed copy. As far as CSS goes, I think that it prints websites using the style sheets that are defined for printing, just as you would expect from a real printer.