mkdocs-print-site-plugin
mkdocs-print-site-plugin copied to clipboard
Printing to PDF from Chrome results in mal-formatted pdf with broken links
Trying to print from Chrome 126.0.6478.127 results in a pdf with links that redirect to the wrong sections (pages) and, if the book is long enough, an "a number is out of range" error message from Adobe Acrobat.
I did try creating a new minimal mkdocs site, and the TOC links still redirected to the wrong pages in the pdf, but that site (just one section of our user guide) was not long enough to trigger the number out of range error.
mkdocs.yml below without our entire nav section. Note that the nav works on the mkdocs-generated site and on the print-site.html page, it just isn't working in the pdf.
site_name: User Guide
dev_addr: "127.0.0.1:7984"
# Add repository metadata for more integration and ease-of-use
repo_name: Github
edit_uri: "docs/"
theme:
name: material
# palette:
#
# # Palette toggle for automatic mode
# - media: "(prefers-color-scheme)"
# toggle:
# icon: material/brightness-auto
# name: Switch to light mode
#
# Palette toggle for light mode
# - media: "(prefers-color-scheme: light)"
# scheme: default
# toggle:
# icon: material/brightness-7
# name: Switch to dark mode
# Palette toggle for dark mode
# - media: "(prefers-color-scheme: dark)"
# scheme: slate
# toggle:
# icon: material/brightness-4
# name: Switch to system preference
custom_dir: docs/overrides
features:
- navigation.sections
- navigation.path
- navigation.instant
- navigation.tracking
- navigation.top
- navigation.prune
- navigation.indexes
- search.suggest
- search.highlight
- content.tabs.link
- content.code.copy
- content.tooltips
language: en
logo: stylesheets/logo-dark-bkg.png
font:
text: "IBM Plex Sans"
code: "Roboto Mono"
extra_css:
- stylesheets/extra.css
- stylesheets/neoteroi-mkdocs.css
plugins:
- search
- git-revision-date
- macros
- mkdocs-video
- offline
- autorefs
- print-site:
enabled: !ENV [ENABLED_PRINT_SITE, False]
exclude:
- appendices/DEPENDENCIES.md
- appendices/oss-licenses.md
- appendices/mitre-attack.md
- appendices/bundled-servers.md
- start-here/video-list.md
add_full_urls: false
enumerate_headings: false
print_site_banner_template: docs/stylesheets/print_site_banner.tpl
add_cover_page: true
cover_page_template: docs/stylesheets/front.tpl
add_print_site_banner: true
markdown_extensions:
- toc:
toc_depth: 0
permalink: "🔗"
- abbr
- pymdownx.highlight
- pymdownx.inlinehilite
- pymdownx.snippets
- admonition
- footnotes
- neoteroi.cards
- pymdownx.details
- pymdownx.mark
- pymdownx.smartsymbols
- pymdownx.keys
- pymdownx.tabbed
- pymdownx.tasklist
- attr_list
- md_in_html
- pymdownx.superfences
exclude_docs: |
node_modules
.DS_Store
npm-debug.log
dist
styles
*.py
site/
.gitignore
start-here/release-notes.md
old/*
validation:
links:
absolute_links: warn
anchors: warn
unrecognized_links: warn
nav:
- Start Here:
- index.md
These were all working in late May with our same environment, but by early June, the pdf links quit working correctly. I suspect a Chrome update broke something, as I hadn't upgraded the other tools until I ran into this issue, and it broke anyway.
I tried upgrading mkdocs, mkdocs-material, Acrobat, and mkdocs-print-site-plugin, but no change. Current versions are:
mkdocs --version mkdocs, version 1.6.0 from /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/mkdocs (Python 3.12)
pip3 show mkdocs-material Name: mkdocs-material Version: 9.5.28 Summary: Documentation that simply works Home-page: Author: Author-email: Martin Donath [email protected] License: Location: /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages Requires: babel, colorama, jinja2, markdown, mkdocs, mkdocs-material-extensions, paginate, pygments, pymdown-extensions, regex, requests Required-by: mkdocs-exporter, mkdocs-print-site-plugin
pip3 show mkdocs-print-site-plugin Name: mkdocs-print-site-plugin Version: 2.5.0 Summary: MkDocs plugin that combines all pages into one, allowing for easy export to PDF and standalone HTML. Home-page: https://github.com/timvink/mkdocs-print-site-plugin Author: Tim Vink Author-email: [email protected] License: MIT Location: /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages Requires: mkdocs-material Required-by:
#128 will refactor the numbering section and should this this also.
if the book is long enough, an "a number is out of range" error message
Wow, writing books in mkdocs-material? I would probably go for something more purpose built like https://quarto.org/docs/books/