Есть ли способ распечатать один пост в теме?

Is there a way to print a single post in a topic, rather than the entire topic?

2 лайка

Not really, you can do something like https://meta.discourse.org/raw/79562/78 to get the raw markdown, but it’s raw markdown and not pretty.

2 лайка

I raised the question of better print support in today’s AMA session, here’s an old topic where I raised similar issues on META that I offered to revive. (I think there may have been a second one, too.)

Something that would allow selecting which posts to include when printing a thread would be very helpful.

Options for formatting of printed output would be helpful too, because good formatting for on-screen presentation isn’t necessarily the same thing as good formatting for printed output.

2 лайка

There is separate css for print.

Selective printing of posts is not something I’m sure how to do.

1 лайк

I did try to experiment with this. It kind of works, but it has some drawbacks I would need to address.

You would have different ways to print a post as PDF:

  • Using a third-party library that converts HTML to PDF (usually reads the HTML node, tries to clone the CSS, and generates a PDF from scratch (or it converts to a canvas, then a PDF) – Usually heavy and prone to limitations.

  • Opening a window and cloning HTML/CSS. Then, you trigger the OS print function for that window. Extracting/setting CSS properly seems unreliable/slow, doesn’t honor the print style, and the window may be blocked.

  • Using the native OS print function “Save to PDF”: – The main issue is telling the OS what to print.

(I did not investigate everything)

I tried the latter and found a CSS trick (not from me) that essentially isolates the post (meaning hiding everything else) and then programmatically runs the OS print function.

Demo:

Few issues as it is:

  • You lose the previous post position when styles are unhidden.
  • Sometimes, elements are not hidden fast enough before the print window is opened.

It’s a little tricky, but it works, and relying on the OS is a big prop, in my opinion. :smile:

2 лайка

Well, there’s a way for moderators to select posts when moving them, so the code for selecting posts already exists, what would (probably) be needed is a way to turn those selected posts into something printable.

1 лайк

That’s true! It should be possible to make that code callable for the print all function. If you have a budget and are self hosted (or on enterprise) it should be possible.

EDIT: Wait. Wait. Wait. As I remember, Control-P gives a view of an entire topic, but I tried it just now and it has just

I thought it might be something just on meta, but I tried a couple of other forums and it’s not providing all of the posts. This seems like a bug, but I obviously haven’t paid close attention to this in some years.

1 лайк

And what’s odd is if you’re NOT logged in, it seems to give you the whole topic. That’s still not what I’d like but it might be an improvement over just doing a print from within the browser.

This is a bug we noticed today already and a fix is in the works.

I shared the idea of selecting posts to print or export internally. No idea of if or when we will work on this but that something should be done is on our radar.

4 лайка

There is an alpha TC for it:

2 лайка

In our communities we still see the need for sharing of internal information from discourse into other platforms, eg. a signal or threema chat group. For this use case, a particular post (e.g. the protocol of a meeting which was created collaboratively as wiki text) should be selectable for printing and export as pdf.

Have you looked at the Theme Component I referenced above? It would do that just fine.

only works for staff

Hi @nathank- I played with GitHub - discourse/clean-export · GitHub . You are right, is seems to require TL4 or admin permissions.

We should modify it so that the button appears at the lower TL levels too.

yea it would then have to be removed from the post admin menu (wrench) to the regular post menu.

Are you sure? Lower trust levels get the admin wrench when they are able to make Wiki posts.

1 лайк

… and the wiki permission is linked to the edit_wiki_post_allowed_groups setting

I could live with such a restriction, if its technically inevitable. From a security perspective, printing of a topic has the same “risk” as printing of the whole thread.

1 лайк