Printer Friendly CSS

PR submitted (images attached to GitHub PR)

@ky_metro, I incorporated all of your adjustments, I think they worked out well.

8 Likes

Actually, this is not entirely true. Here’s how to do it… involves disabling javascript in your browser before loading the topic. Produces a very passable view suitable for printing or saving as PDF.

I am extremely excited to see this pull request and discussion happening - print view is one of the most asked for features for my community… we have alot of folks in “internet remote” locations who would love to download and read topics offline. Also we use discourse for collaboratively creating documentation that we’d like to be able to share beyond discourse.

What I would really like actually is a link on the sharing link on the popup that then downloads as a PDF the whole shebang (when sharing link at bottom is used) or just an individual post (when the post timestamp is used). That can then be shared or printed out.

Well, yes, if you wish to take the time to do it page by page and then combine them all. My point was, there isn’t a “all posts in one output” availability to Discourse.

Not sure what you mean… it’s a quick process to turn off javascript, open the page, save as PDF. It saves the whole shebang.

Here’s an example:

But it isn’t the “whole enchilada”. It’s paginated. i.e. AFAIK you can’t load a > 20 posts topic all in 1 go.

Ah. Gotcha. That hasn’t been an issue in our smaller community, and in any case we’ve been mostly interested in sharing topics we’ve been collaboratively developing as documentation.

So my community would be interested enough in this to contribute $$$ to have it developed and contributed to discourse, perhaps as a plugin if that’s possible or as core if it’s so desired. Happy to take proposals.

The whole enchilada is going to be tricky, it is going to have to have some hard limit as well, printing a 20000 post topic for example is going to lead to much pain

2 Likes

I’m sure it could be done. My main thoughts were “something is better than nothing” and the New England Yankee in me not wanting to use twice as many pages to print content and a mess of action buttons and link text that meant nothing on a printed page. Not that paper and ink are all that expensive, just the same, why use 8 sheets when 4 will do?

* to clarify, I personally do not print topics, but others do. More of a “in their shoes” thing.

Maybe save to pdf (of topics over 20 pages and therefore requiring pagination) could be handled like a backup? e.g. start creating the PDF as a background task and send me a PM with the link to download?

Or perhaps limit the save to PDF to post, all topics if under 20 topics, or to topic summary which would also be within the 20 topic length.

Edit: Would the inclusion of this PR make Discourse more Pocket-friendly? I’ll be sure to test that for you as soon as this is live on Meta.

On a different note, for those more edge case scenarios, I’m sure there’s all sorts of wizardry to explore on the client-side alone. Just thought of this thread when I noticed this on HN today:

Pretty Print Gmail - Chrome Extension

Is it possible to target the print version of a specific topic with CSS? For example, if I have one topic that is a manual (ie. not just the first post but the entire topic is the manual, with different posts containing different sections of the manual), I’d like to hide post number, user names and post date (and possibly a few other things) from the print layout.

A workaround seems to be that I put that topic into its own category and then target the category, but maybe there is a better way?

When printing it would also be nice if the entire topic, rather than just the first 20 posts, we loaded.

What’s the use case for printing a 100 reply topic, exactly? Or a 1000 reply topic? Surely there has to be a limit.

I’m working with researchers who want forum data for offline analysis. One forum that I scraped recently included a print option which gave whole threads rather than splitting into multiple pages,which made the job much easier. In the particular instance it was scraping a public forum, but it’s often useful for those who want to analyze their own forum data.

I agree that some limit of posts would make sense (1000 perhaps?)

2 Likes

Why are you scraping when you can use the JSON API?

On the site I scraped recently there was no api.

I’ve written a discourse scraper before, but it’s nice to be able to easily reproduce formatting stuff that a scraper would need to handle from scratch.

I helped work on a print.css quite a while ago. By eliminating useless navigation, post and topic actions, reducing print size, margins and padding, etc. we were able to get the twenty posts down to around, IIRC, 4-5-ish print pages. Dependent on post content of course.

Perhaps it isn’t as expensive to run off reams as I think it would be. But in any case it would be extremely unlikely that I would want an entire discussion. And if I did I would want it bad enough that I would be willing to print the paginated posts in a repeated process.

4 Likes

We do this already! Just press CTRL+P.

6 Likes

And I’m pretty sure the print view is limited to exactly 1000 posts already…

3 Likes

Oh. I think I remember that now that you say it! Sorry about that.

Oh, and this is what I don’t like about suggested topics. I didn’t realize that was restarting a topic that was half a year old.