[HN Gopher] CSS for printing to paper
       ___________________________________________________________________
        
       CSS for printing to paper
        
       Author : Tomte
       Score  : 44 points
       Date   : 2024-03-03 21:22 UTC (1 hours ago)
        
 (HTM) web link (voussoir.net)
 (TXT) w3m dump (voussoir.net)
        
       | n3storm wrote:
       | I would love to see some svg thrown into this.
       | 
       | Let's kill pdf!
        
         | mcdonje wrote:
         | So... Epub?
        
           | Turing_Machine wrote:
           | EPUB is great for its use case, but is not particularly good
           | at handling printing. Not even EPUB3 does a good job for
           | print, IMO.
        
         | h2odragon wrote:
         | .ps.gz forevah!
        
         | wiredfool wrote:
         | Or, lets try to get SVG graphs to render properly in print-to-
         | pdf?
        
       | herpdyderp wrote:
       | I recently had to figure out a good chunk of this (on my own, I
       | wish I had this resource then) for a one-off project. The biggest
       | thing I learned was to give up all hope of cross-browser
       | printing: just use Chrome. Every browser treats almost every
       | property differently or flat out ignores them, but I found that
       | Chrome had the highest score in doing what I wanted.
        
         | gazook89 wrote:
         | There are two sites that share a common history that provide a
         | tool for TTRPG players to create homebrew documents, GM Binder
         | and Homebrewery, that both only target Chrome for this reason.
         | It's great if we can support all browsers and don't want the
         | site to break in any browser, but we advise users that Chrome
         | is the target almost just so we know authors and readers are on
         | the same page.
        
       | a1o wrote:
       | I almost never do real printing (to paper), but this looks really
       | easy to get something working. Also the cheatsheet at the end of
       | the article is a super useful summary of the css rules used.
       | Great article to save in case I face having to build something
       | that prints in the future.
        
       | persnickety wrote:
       | Browser support for printing CSS is spotty. Worse: some features,
       | like footnotes on every page, don't have any equivalent in CSS I
       | know of.
       | 
       | Is there any easy to use/hack HTML layouting engine where I could
       | experiment with custom CSS attributes and bridge that gap? Would
       | anything from Servo be suitable?
       | 
       | Modifying an entire browser with its bloat is too much effort.
       | There is no JS or cookies on paper (they can be in paper if you
       | wrap them).
        
         | kabes wrote:
         | Css has support for footnotes, but it's not yet supported by
         | chrome
        
       | didgeoridoo wrote:
       | I just laid out a book using Pagedjs.org. Although there were a
       | few bugs in the preview experience, the final output was perfect,
       | and probably took me a quarter the time it would have in InDesign
       | (which I'm fairly competent in).
       | 
       | The real power is in being able to hook up all the templating,
       | CMS APIs, and whatever else you want into your content pipeline.
       | It's Just HyperText(tm).
       | 
       | I'd go so far to say that if you're equally comfortable in
       | HTML/CSS and InDesign, Pagedjs is a superior choice for long form
       | layout.
        
       | fifilura wrote:
       | I can't help but feel like this is going full circle.
       | 
       | CSS started with print media in mind since this was what was
       | available at the time.
       | 
       | Many of these features have been there since the inception. Just
       | that browser support has been lagging.
       | 
       | How do you break a table inside a float? Etc.
        
       | account-5 wrote:
       | I'm pretty sure I've used https://github.com/cognitom/paper-css
       | before for generating pdfs via the browser.
        
       | bradgessler wrote:
       | Browser support for printing is so bad that I'm going to have to
       | create a native app for https://www.thingybase.com to have a
       | streamlined workflow of printing labels to a thermal label
       | printer.
       | 
       | It works now, but first you have to download a PDF and print
       | that. Google Docs does this too when you hit "Print".
       | 
       | I've tried hacks like load the PDF in an iframe and use some
       | JavaScript to print that, but then I get footers with the URL of
       | the webpage, which doesn't work for my purposes.
       | 
       | If you work on Chrome/Blink, Safari/Webkit, or Firefox/Mozilla
       | please please please at least get the hacks working!
       | 
       | A CSS standard would be great, but really I'd be happy if I could
       | call a function like `windows.print("/document.pdf")` and have it
       | print the PDF without all the footer/headers stuff.
        
         | IgorPartola wrote:
         | I've worked with thermal printers and they are actually quite
         | capable. They have drawing primitives that allow you to lay out
         | basic graphics and the one I was working with even had basic
         | font support. A native driver is definitely the way to go with
         | these.
        
       ___________________________________________________________________
       (page generated 2024-03-03 23:00 UTC)