Customizable Print to PDF Button

I wanted to give my users a more elegant way to print the contents of a topic than the stock print method. This allows specifying specifically which topics the button appears in, adding or removing elements, and adding a table of contents if the user wants it.


Screenshots

It mimics your site’s button styles, providing both primary and secondary color palettes.

When a table of contents is detected, the option to include/exclude the outline is provided:

:white_check_mark: I also added the ability to limit how deep the table of contents looks for headers, to help balance usefulness and practicality.

See the Theme Creator Site for a live demo of an outline being added. I couldn’t figure out how to enable DiscoTOC there, but it’s detecting it anyway :sweat_smile:.


Settings

Setting Description
enabled_categories Categories where the button appears
enabled_tags Tags where the button appears
enabled_topic_ids Specific topic IDs to always show the button
first_post_only Only include the original post
show_post_meta Show author and date in the PDF
show_site_logo Show the site logo in the PDF header
show_tags Show topic tags in the PDF header
show_toc Enable the outline feature and checkbox
toc_max_depth Heading depth for the outline
button_style Secondary (outline) or primary (filled)

I built this without using the object editor, but now I can see some value in having different button treatments depending on where it is located. Such as including the first post only or including/excluding author data. Happy to hear thoughts and tweak it though!

7 Likes