将主题打印为PDF

:bookmark: This guide explains how to print/download any Discourse topic to PDF.

:person_raising_hand: Required user level: All users

Discourse allows you to generate a PDF of a topic by using the Print topic keyboard shortcut. The shortcut for your system is noted in the keyboard shortcut reference modal that pops up when you press the ? key while browsing a Discourse site.

  • Most operating systems: ctrl+p
  • MacOS: +p

Using the shortcut will open a new browser window where you can optionally choose to print the topic as a PDF. The interface will vary by browser, but it will look something like the example below:

Additional Information

  • Discourse intercepts the keyboard shortcut and renders the print view server-side to ensure the entire topic is printed.

  • The same functionality can be triggered by appending /print to the end of a topic’s URL.

  • You can technically select the print option in your browser’s File menu as well, but you will likely need to scroll from the first post to the last post of the topic to ensure all of the posts have loaded into view.

  • There is a max prints per hour per user site setting that allows an admin to set a maximum number of /print page impressions per hour per user. It defaults to 5 and can be set to 0 to disable Discourse’s topic printing functionality (printing from the browser menu still works).

Last edited by @tshenry 2024-08-01T01:14:43Z

Last checked by @hugh 2024-07-02T05:14:01Z

Check documentPerform check on document:
30 个赞

将所有内容输出到 PDF 文件非常好。

虽然我发现使用子项时内容格式会略有改变。

就像此内容的输出一样

  • Level1
    • Level2
    • Level2
      • Level3
      • Level3

但打印到 PDF 文件时,所有项目都将左对齐,就像所有项目都是 Level1 项目一样。

有什么办法可以解决这个问题,例如进行一些设置,使其打印效果与 HTML 视图中的完全一样吗?

4 个赞

另外,是否可以只打印单个帖子?如果我尝试 https://meta.discourse.org/t/printing-a-topic-as-a-pdf/160061/1/print,我会收到一个错误。

如果帖子有一个有价值的 OP(原始帖子)和一堆价值不高的回复,那么只打印单个帖子会非常有帮助。

目前还不行。Tobias 曾表示团队可能会在某个时候考虑这个问题。

5 个赞

嗯,我有一个解决办法。

我通常会为打印创建一个新帖子。

然后选择多个帖子,并将它们按逻辑顺序写入一个新主题,然后打印这个完整的主题。之后删除这个完整的主题。

比如我想选择第 1、3、4、5、7、12 篇帖子,组成一个逻辑顺序的主题,这将是一个完整的故事,然后打印这个选定的故事。


太棒了,这一定是最好的方法!

1 个赞

这听起来很有效,但有点破坏性。不过,由于这项功能,如今重新组装主题应该不难:

1 个赞

我们仍然需要记录这些,但在此期间可以先看看以下主题组件:

10 个赞

可以各发一张截图吗?

我在“post wrench”中找到了“print post”,但找不到其他按钮

已安装两者。

我得到一个漂亮的打印机图标在右上角。但它没有显示 DiscoTOC 是否处于活动状态:

就我个人而言,如果它也出现在底部的选项中(或者更好的是,我们可以在两个位置之间选择),我会觉得更好。

5 个赞

好的,手机上没有按钮?

至少我没注意到。我在帖子的扳手菜单中有打印单个帖子。

2 个赞

我已更新上面的帖子,添加了截图和一些额外细节。

5 个赞

您认为这种支持会#官方化吗? 恰巧今天有人对导出/共享某个主题感兴趣 :smiley:

3 个赞
  • GitHub - discourse/discourse-topic-print-component 3 (在主题时间线上添加一个按钮,以执行与键盘快捷键相同的操作。对所有用户显示。仅限桌面。)

是否有办法支持移动设备?

2 个赞

这在您赶时间的时候很有帮助。它非常高效。

3 个赞

我也想知道

3 个赞

手机已经有支持了,至少iPhone是有的(不过截图来自iPad/DiscourseHub)

别让奇怪的语言吓到你。但我确信,所有移动系统都具备相同的功能。

所以,Discourse 不需要提供设备已经提供的功能。它也不应该这样做。

我在 Android 上看不到它

有点目光短浅,因为桌面已经提供了 Ctrl+P。人们可以得出同样的结论,即添加一个直接按钮是不必要的。 :wink:

1 个赞

:thinking: 机器人真的就这么有限吗?我的意思是,这已经是基本功能很久了。

这可能有点目光短浅,但我实在看不出有什么意义要设置重叠菜单。因为那样的话,Discourse 也应该提供纯粹的剪切、复制和粘贴功能。

但是,如果,或者我应该说,当出现不提供伪打印/保存为 PDF 的系统时,那么这个功能就是需要的。

2 个赞

:sweat_smile: 各位请耐心等待,我们目前甚至还没有这两个组件的文档主题!等我们着手处理时,再收集其他反馈/请求。同时,这些是开源且获得 MIT 许可的,因此如果您有特别紧急的需求,可以随意分叉和/或提交拉取请求。

7 个赞

我认为我终于找到了一个好办法

  • 我们不必输出为pdf。
    我们可以将整个网页输出为html文件。
    只需使用Chrome网上应用店中的SingleFile,它将下载并压缩完整的网页,并将其保存为html文件。

  • 如果您想打印为pdf,请使用下载的html文件进行打印,它将保留html文件中的所有格式。

2 个赞