### Install MkDocs Exporter Plugin Source: https://github.com/adrienbrignon/mkdocs-exporter/blob/master/docs/getting-started.md Installs the MkDocs Exporter plugin using pip. This is the primary method for adding the plugin to your MkDocs project. Ensure you have Python and pip installed. ```shell pip install mkdocs-exporter ``` -------------------------------- ### MkDocs Exporter Installation and Setup (Bash) Source: https://context7.com/adrienbrignon/mkdocs-exporter/llms.txt Guides through the installation of MkDocs Exporter using pip and Playwright for browser dependencies. Includes commands for development installation, verification, building, serving, and overriding build configurations. ```bash # Install the plugin pip install mkdocs-exporter # Install Playwright browser (required for PDF generation) playwright install chromium --with-deps # For development installation git clone https://github.com/adrienbrignon/mkdocs-exporter.git cd mkdocs-exporter pip install -e . playwright install chromium --with-deps # Verify installation python -c "import mkdocs_exporter; print('MkDocs Exporter installed successfully')" # Build documentation with PDF generation mkdocs build # Serve with live reload (PDFs regenerate on changes) mkdocs serve # Build with environment variable overrides MKDOCS_EXPORTER_PDF=true MKDOCS_EXPORTER_PDF_AGGREGATOR=true mkdocs build ``` -------------------------------- ### Configure MkDocs Exporter Plugin in mkdocs.yml Source: https://github.com/adrienbrignon/mkdocs-exporter/blob/master/docs/getting-started.md Registers the MkDocs Exporter plugin in your MkDocs configuration file (mkdocs.yml). This enables the plugin's functionality for your documentation site. Requires the plugin to be installed first. ```yaml plugins: - exporter ``` -------------------------------- ### Install MkDocs Exporter (Bash) Source: https://github.com/adrienbrignon/mkdocs-exporter/blob/master/README.md Installs the MkDocs exporter plugin using pip to enable PDF export functionality. Requires Python >= 3.9 and MkDocs >= 1.4 as prerequisites. Outputs the installed plugin ready for configuration. ```bash pip install mkdocs-exporter ``` -------------------------------- ### Install Playwright Dependencies Source: https://github.com/adrienbrignon/mkdocs-exporter/blob/master/docs/configuration/generating-pdf-documents.md Installs the Playwright browser and its required dependencies, specifically Chrome, for PDF generation. This command is essential for the library's PDF generation capabilities. ```bash playwright install chrome --with-deps ``` -------------------------------- ### Convert HTML to PDF using Browser Control (Python) Source: https://context7.com/adrienbrignon/mkdocs-exporter/llms.txt Demonstrates low-level browser control for converting HTML content to PDF. It initializes a browser instance with custom arguments, launches it, converts provided HTML, and saves the resulting PDF. Ensure 'mkdocs-exporter' is installed. ```python import asyncio from mkdocs_exporter.formats.pdf.browser import Browser async def convert_html_to_pdf(): # Initialize browser with custom arguments browser = Browser({ 'headless': True, 'timeout': 60000, 'debug': True, 'args': [ '--disable-gpu', '--font-render-hinting=none' ] }) # Launch the browser (thread-safe) await browser.launch() # HTML content to convert html = """

Document Title

Content that will be converted to PDF.

""" try: # Convert HTML to PDF pdf_data, pages = await browser.print(html) print(f"Generated {pages} pages") print(f"PDF size: {len(pdf_data)} bytes") # Save PDF with open('output.pdf', 'wb') as f: f.write(pdf_data) finally: # Always close browser await browser.close() asyncio.run(convert_html_to_pdf()) ``` -------------------------------- ### Page-Specific Buttons with Jinja (YAML/HTML) Source: https://github.com/adrienbrignon/mkdocs-exporter/blob/master/docs/configuration/adding-buttons-to-pages.md Example of configuring page-specific buttons using front matter. It utilizes Jinja templating to dynamically render button properties based on the page's metadata. ```yaml --- {% set button = page.meta.buttons[0] -%} buttons: - title: {{ button.title }} icon: {{ button.icon }} attributes: class: {{ button.attributes.class }} href: {{ button.attributes.href }} target: {{ button.attributes.target }} --- # {{ page.title }} ``` -------------------------------- ### Configure MkDocs Exporter (YAML) Source: https://github.com/adrienbrignon/mkdocs-exporter/blob/master/README.md Configures the exporter plugin in mkdocs.yml to enable PDF generation with options for concurrency, stylesheets, cover pages, and document aggregation. Requires MkDocs with the plugin installed; inputs include environment variables and file paths. Generates customized PDF outputs but is limited to supported MkDocs themes like Material and ReadtheDocs. ```yaml plugins: - exporter: formats: pdf: enabled: !ENV [MKDOCS_EXPORTER_PDF, true] concurrency: 8 stylesheets: - resources/stylesheets/pdf.scss covers: front: resources/templates/covers/front.html.j2 back: resources/templates/covers/back.html.j2 aggregator: enabled: true output: .well-known/site.pdf covers: all ``` -------------------------------- ### Enable PDF Export in MkDocs (mkdocs.yml) Source: https://context7.com/adrienbrignon/mkdocs-exporter/llms.txt Minimal MkDocs plugin configuration to enable PDF export. Activate the exporter and specify the 'pdf' format. Useful as a starting point before adding advanced options. ```yaml plugins: - exporter: formats: pdf: enabled: true ``` -------------------------------- ### Aggregate Multiple PDFs with Cover Strategies (Python) Source: https://context7.com/adrienbrignon/mkdocs-exporter/llms.txt Details how to combine multiple PDF documents into a single file using specified cover strategies (e.g., 'front', 'book'). It requires a renderer and aggregator instance, mock page objects, and provides a structure for appending PDFs. Assumes 'mkdocs-exporter' is installed. ```python import asyncio from mkdocs_exporter.formats.pdf.renderer import Renderer from mkdocs_exporter.formats.pdf.aggregator import Aggregator from mkdocs_exporter.page import Page async def aggregate_pdfs(): # Create renderer renderer = Renderer(options={}) # Initialize aggregator with cover strategy aggregator = Aggregator( renderer=renderer, config={ 'output': 'combined.pdf', 'covers': 'front' # Options: all, none, limits, book, front, back } ) # Mock page objects (in real usage, these come from MkDocs) pages = [] for i in range(3): page = Page(title=f"Page {i+1}", file=None) page.index = i page.formats = { 'pdf': { 'pages': 2, 'covers': ['front', 'back'], 'path': f'/tmp/page{i}.pdf', 'skipped_pages': 0 } } pages.append(page) # Set pages for aggregation aggregator.set_pages(pages) # Open output file aggregator.open('combined.pdf') # Append each PDF (would need actual PDF files) for page in pages: # In real usage, render pages and append # html = aggregator.preprocess(page) # pdf_data, _ = await renderer.render(html) # aggregator.append(pdf_path) pass # Save aggregated PDF with metadata aggregator.save(metadata={ '/Title': 'Complete Documentation', '/Author': 'Your Name', '/Subject': 'API Documentation' }) await renderer.dispose() asyncio.run(aggregate_pdfs()) ``` -------------------------------- ### Mermaid Flowchart Diagram Source: https://github.com/adrienbrignon/mkdocs-exporter/blob/master/docs/samples/diagrams.md Defines a flowchart using Mermaid syntax. This diagram visualizes a simple decision-making process with start, decision, and end points. ```mermaid flowchart TD A[Start] --> B{Is it?} B -->|Yes| C[OK] C --> D[Rethink] D --> B B ---->|No| E[End] ``` -------------------------------- ### SCSS for Advanced PDF Styling Source: https://context7.com/adrienbrignon/mkdocs-exporter/llms.txt SCSS code for advanced PDF styling using CSS Paged Media specifications. It includes variable definitions, page setup for headers and footers, and specific styling for headings, code blocks, tables, and links. ```scss // resources/stylesheets/pdf.scss // Variables $primary-color: #EA2027; $font-family: 'Roboto', sans-serif; $code-font: 'Roboto Mono', monospace; // Page setup using CSS Paged Media @page { size: A4; margin: 2cm; @top-center { content: string(doctitle); font-size: 10pt; color: #666; } @bottom-right { content: "Page " counter(page) " of " counter(pages); font-size: 10pt; } } // First page has no header @page :first { @top-center { content: none; } } // Set document title for running header h1 { string-set: doctitle content(); } // Avoid page breaks inside code blocks pre, code { page-break-inside: avoid; font-family: $code-font; background-color: #f5f5f5; padding: 0.5em; } // Ensure headings stay with following content h1, h2, h3, h4, h5, h6 { page-break-after: avoid; color: $primary-color; } // Table styling table { page-break-inside: avoid; width: 100%; border-collapse: collapse; th { background-color: $primary-color; color: white; padding: 0.5em; } td { padding: 0.5em; border: 1px solid #ddd; } } // Links in PDF should show URL a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 0.8em; color: #666; } // Cover page specific styles .front-cover, .back-cover { page: cover; page-break-after: always; } @page cover { margin: 0; @top-center { content: none; } @bottom-right { content: none; } } ``` -------------------------------- ### Create front cover HTML template Source: https://github.com/adrienbrignon/mkdocs-exporter/blob/master/docs/configuration/generating-pdf-documents.md Defines the structure of the front cover page using HTML and Jinja2 templating. Includes placeholders for site name and page title, with a background image. Requires a background image file at the specified path. ```html
{% raw %}{{ config.site_name }}{% endraw %}
{% raw %}{{ page.title }}{% endraw %}
``` -------------------------------- ### Configure global PDF covers in mkdocs.yml Source: https://github.com/adrienbrignon/mkdocs-exporter/blob/master/docs/configuration/generating-pdf-documents.md Sets up global front and back cover templates for all PDF documents in the project. Requires defining paths to HTML templates and SCSS stylesheets. This ensures consistent styling across all generated PDFs. ```yaml plugins: - exporter: formats: pdf: stylesheets: - resources/stylesheets/pdf.scss covers: front: resources/templates/covers/front.html.j2 back: resources/templates/covers/back.html.j2 ``` -------------------------------- ### Create back cover HTML template Source: https://github.com/adrienbrignon/mkdocs-exporter/blob/master/docs/configuration/generating-pdf-documents.md Defines the structure of the back cover page using HTML and Jinja2 templating. Displays the site name in a titled section. Simple template with minimal styling requirements. ```html
{% raw %}{{ config.site_name }}{% endraw %}
``` -------------------------------- ### Theme Factory and Custom Themes (Python) Source: https://context7.com/adrienbrignon/mkdocs-exporter/llms.txt Demonstrates the usage of MkDocs Exporter's Theme Factory to create and manipulate theme instances. It covers creating built-in themes, custom themes, applying preprocessing, adding themed elements like buttons, and transforming stylesheets. ```python from mkdocs_exporter.themes.factory import Factory from mkdocs_exporter.preprocessor import Preprocessor # Create Material theme instance material_theme = Factory.create('material') # Create ReadTheDocs theme instance rtd_theme = Factory.create('readthedocs') # Use custom theme class (must be in config) custom_theme = Factory.create({'name': 'custom', 'custom_dir': 'theme'}) # Apply theme preprocessing html = "
Content
" preprocessor = Preprocessor(html, theme=material_theme) # Theme-specific cleanup (removes nav, sidebars, etc.) material_theme.preprocess(preprocessor) # Add themed button material_theme.button( preprocessor, title="Download", icon="material-download", attributes={'href': '/file.pdf'} ) # Process theme stylesheets css_content = "body { color: red; }" transformed_css = material_theme.stylesheet(None, css_content) result = preprocessor.done() ``` -------------------------------- ### Preprocess HTML with Theme and Manipulations (Python) Source: https://context7.com/adrienbrignon/mkdocs-exporter/llms.txt Shows how to preprocess HTML for PDF generation using a theme and applying various manipulations. It supports theme-specific preprocessing, attribute setting, CSS/JS injection, element removal, link updates, and metadata injection. Requires 'mkdocs-exporter'. ```python from mkdocs_exporter.preprocessor import Preprocessor from mkdocs_exporter.themes.factory import Factory # Create theme instance theme = Factory.create('material') # Initialize preprocessor with HTML html = """ Test
This will move to body end
Will be removed
DetailsContent
""" preprocessor = Preprocessor(html, theme=theme) # Apply theme-specific preprocessing theme.preprocess(preprocessor) # Open all details elements preprocessor.set_attribute('details:not([open])', 'open', 'open') # Inject custom stylesheet (supports SCSS) custom_css = """ $primary-color: #EA2027; body { color: $primary-color; font-family: Arial, sans-serif; } """ preprocessor.stylesheet(custom_css) # Inject custom JavaScript preprocessor.script(""" console.log('Custom script loaded'); window.MkDocsExporter = { render: async function(config) { console.log('PDF rendering started'); } }; """) # Add a themed button preprocessor.button( title="Download PDF", icon="material-download", attributes={ 'href': '/path/to/file.pdf', 'download': 'document.pdf' } ) # Teleport elements with data-teleport attribute preprocessor.teleport() # Remove unwanted elements preprocessor.remove(['.remove-me', 'nav', 'footer']) # Update relative links to absolute file:// URLs preprocessor.update_links('/path/to/base', '/path/to/root') # Inject metadata preprocessor.metadata({ 'page': 1, 'pages': 10, 'title': 'Document Title' }) # Get processed HTML result_html = preprocessor.done() print(result_html) ``` -------------------------------- ### Advanced MkDocs PDF Configuration (mkdocs.yml) Source: https://context7.com/adrienbrignon/mkdocs-exporter/llms.txt Full-featured MkDocs configuration showing debug logging, concurrency, custom stylesheets and scripts, front/back covers, browser options, URL base, and aggregation into a single PDF. Intended for production-grade PDF builds. ```yaml plugins: - exporter: logging: level: debug formats: pdf: enabled: !ENV [MKDOCS_EXPORTER_PDF, true] concurrency: 16 explicit: false stylesheets: - resources/stylesheets/pdf.scss scripts: - resources/scripts/custom.js covers: front: resources/templates/covers/front.html.j2 back: resources/templates/covers/back.html.j2 browser: debug: false headless: true timeout: 60000 args: - --disable-gpu url: https://docs.example.com aggregator: enabled: true output: documentation.pdf covers: front buttons: - title: Download as PDF icon: material-file-download-outline enabled: !!python/name:mkdocs_exporter.formats.pdf.buttons.download.enabled attributes: !!python/name:mkdocs_exporter.formats.pdf.buttons.download.attributes ``` -------------------------------- ### Mermaid Sequence Diagram Source: https://github.com/adrienbrignon/mkdocs-exporter/blob/master/docs/samples/diagrams.md Illustrates a sequence diagram using Mermaid syntax. This diagram shows interactions between different participants over time. ```mermaid sequenceDiagram Alice->>John: Hello John, how are you? John-->>Alice: Great! Alice-)John: See you later! ``` -------------------------------- ### Concurrent PDF Generation (Python) Source: https://context7.com/adrienbrignon/mkdocs-exporter/llms.txt Illustrates how to efficiently generate multiple PDFs in parallel using Python's asyncio and the `concurrently` helper function from MkDocs Exporter. It shows how to define asynchronous rendering tasks and control the concurrency limit. ```python import asyncio from mkdocs_exporter.helpers import concurrently async def render_page(page_num): """Simulate PDF rendering task.""" await asyncio.sleep(1) # Simulate work print(f"Rendered page {page_num}") return page_num async def batch_render(): # Create tasks for 20 pages tasks = [render_page(i) for i in range(20)] # Run with concurrency limit of 4 # This ensures only 4 PDFs are generated simultaneously async for result in concurrently(tasks, concurrency=4): print(f"Task {result} completed") asyncio.run(batch_render()) ``` -------------------------------- ### Jinja2 Front Cover Template Source: https://context7.com/adrienbrignon/mkdocs-exporter/llms.txt A Jinja2 template for creating a custom front cover page for PDFs. It includes dynamic elements like the logo, page title, description, version, date, author, site name, and URL. ```jinja2

{{ page.title }}

{{ page.meta.description | default('Documentation') }}

``` -------------------------------- ### Add Download Button (YAML) Source: https://github.com/adrienbrignon/mkdocs-exporter/blob/master/docs/configuration/adding-buttons-to-pages.md Configuration to add a download button for PDF documents. It specifies the button's title, icon, and uses Python functions to dynamically determine its enabled status and attributes. ```yaml plugins: - exporter: buttons: - title: Download as PDF icon: material-file-download-outline enabled: !!python/name:mkdocs_exporter.formats.pdf.buttons.download.enabled attributes: !!python/name:mkdocs_exporter.formats.pdf.buttons.download.attributes ``` -------------------------------- ### Programmatic PDF Rendering (Python) Source: https://context7.com/adrienbrignon/mkdocs-exporter/llms.txt Direct usage of the PDF renderer to generate PDFs from HTML using Playwright/Chromium. Initializes browser and renderer options, adds custom assets, renders HTML to PDF bytes and page count, saves output, and disposes resources. ```python import asyncio from mkdocs_exporter.formats.pdf.renderer import Renderer from mkdocs_exporter.formats.pdf.browser import Browser async def generate_pdf(): # Initialize browser with custom options browser = Browser({ 'headless': True, 'timeout': 60000, 'debug': False }) # Create renderer with browser and configuration renderer = Renderer(browser=browser, options={ 'browser': {'headless': True}, 'url': 'https://example.com' }) # Add custom stylesheets and scripts renderer.add_stylesheet('path/to/custom.scss') renderer.add_script('path/to/custom.js') # Prepare HTML content html_content = """ Test Document

Test Content

This will be converted to PDF.

""" # Render to PDF (returns tuple of bytes and page count) pdf_bytes, page_count = await renderer.render(html_content) print(f"Generated PDF with {page_count} pages") # Save to file with open('output.pdf', 'wb') as f: f.write(pdf_bytes) # Clean up await renderer.dispose() # Run the async function asyncio.run(generate_pdf()) ``` -------------------------------- ### Mermaid Class Diagram Source: https://github.com/adrienbrignon/mkdocs-exporter/blob/master/docs/samples/diagrams.md Represents a class diagram using Mermaid syntax. This diagram visualizes the structure of a system, showing classes, their attributes, methods, and relationships. ```mermaid classDiagram note "From Duck till Zebra" Animal <|-- Duck note for Duck "can fly\ncan swim\ncan dive\ncan help in debugging" Animal <|-- Fish Animal <|-- Zebra Animal : +int age Animal : +String gender Animal: +isMammal() Animal: +mate() class Duck{ +String beakColor +swim() +quack() } class Fish{ -int sizeInFeet -canEat() } class Zebra{ +bool is_wild +run() } ``` -------------------------------- ### Jinja2 Back Cover Template Source: https://context7.com/adrienbrignon/mkdocs-exporter/llms.txt A Jinja2 template for creating a custom back cover page for PDFs. It displays information about the document's origin and provides a link to the website. ```jinja2

About This Document

This document was generated using MkDocs Exporter.

For the latest version, visit: {{ config.site_url }}

``` -------------------------------- ### Per-Page PDF Overrides Using Frontmatter Source: https://context7.com/adrienbrignon/mkdocs-exporter/llms.txt Per-page frontmatter to enable/disable PDF for specific pages, select custom covers, hide covers globally, or add page-specific download buttons. Overrides the global MkDocs configuration on a page-by-page basis. ```yaml --- # Enable PDF for this specific page pdf: true # Custom cover pages for this page only covers: front: ./custom-front.html.j2 back: ./custom-back.html.j2 # Hide all cover pages hide: - covers # Add page-specific buttons buttons: - title: Custom Download icon: material-star attributes: href: /path/to/custom.pdf download: custom-filename.pdf --- # Your page content here ``` -------------------------------- ### Dynamic Button HREF Function (Python) Source: https://github.com/adrienbrignon/mkdocs-exporter/blob/master/docs/configuration/adding-buttons-to-pages.md A Python function that generates the 'href' attribute for a button. It takes a Page object and keyword arguments, constructs a Google search URL using the page's title as the query, and returns the URL. ```python from urllib.parse import urlencode from mkdocs_exporter.page import Page def href(page: Page, **kwargs) -> str: """The button's 'href' attribute.""" return 'https://google.com/search?' + urlencode({'q': page.title}) ``` -------------------------------- ### Override cover pages per Markdown page Source: https://github.com/adrienbrignon/mkdocs-exporter/blob/master/docs/configuration/generating-pdf-documents.md Overrides global cover pages for specific Markdown pages using front matter configuration. Allows specifying custom front cover templates per page. Can also configure back cover pages similarly. ```markdown --- covers: front: ./resources/templates/covers/special.html.j2 --- # My special page This configuration specifies a custom front cover page template located at `./resources/templates/covers/special.html.j2` for this page. You can follow the same operation to specify a custom back cover page. ``` -------------------------------- ### MkDocs YAML Configuration for Custom Buttons Source: https://context7.com/adrienbrignon/mkdocs-exporter/llms.txt Configuration snippet for mkdocs.yml to integrate custom Python functions for PDF download buttons. It specifies the title, icon, enablement condition, and attributes for the button. ```yaml # mkdocs.yml plugins: - exporter: buttons: - title: !!python/name:buttons.title icon: material-file-download enabled: !!python/name:buttons.enabled attributes: !!python/name:buttons.attributes ``` -------------------------------- ### Python PDF Download Button Logic Source: https://context7.com/adrienbrignon/mkdocs-exporter/llms.txt Python functions to control the visibility, link generation, and attributes of a PDF download button. It checks for PDF format availability and constructs a relative path to the PDF file. ```python from mkdocs_exporter.page import Page import os def enabled(page: Page, **kwargs) -> bool: """Only show button if PDF format is available.""" return 'pdf' in page.formats def href(page: Page, **kwargs) -> str: """Generate relative path to PDF.""" if 'pdf' not in page.formats: return '#' return os.path.relpath(page.formats['pdf']['url'], page.url) def attributes(page: Page, **kwargs) -> dict: """Generate complete button attributes.""" return { 'href': href(page), 'download': f"{page.title}.pdf", 'class': 'pdf-download-button', 'data-page-title': page.title } def title(page: Page, **kwargs) -> str: """Dynamic button title.""" if 'pdf' in page.formats: pages = page.formats['pdf']['pages'] return f"Download PDF ({pages} pages)" return "Download PDF" ``` -------------------------------- ### Mermaid Quadrant Chart Source: https://github.com/adrienbrignon/mkdocs-exporter/blob/master/docs/samples/diagrams.md Creates a quadrant chart using Mermaid syntax. This chart is used to visualize data points across two axes, often for strategic analysis like reach and engagement. ```mermaid quadrantChart title Reach and engagement of campaigns x-axis Low Reach --> High Reach y-axis Low Engagement --> High Engagement quadrant-1 We should expand quadrant-2 Need to promote quadrant-3 Re-evaluate quadrant-4 May be improved Campaign A: [0.3, 0.6] Campaign B: [0.45, 0.23] Campaign C: [0.57, 0.69] Campaign D: [0.78, 0.34] Campaign E: [0.40, 0.34] Campaign F: [0.35, 0.78] ``` -------------------------------- ### Custom JavaScript Hooks for PDF Rendering Source: https://context7.com/adrienbrignon/mkdocs-exporter/llms.txt Provides JavaScript hooks to customize MkDocs Exporter's PDF rendering process. It allows modification of configuration, access to page metadata, and preprocessing of HTML content before PDF generation. Dependencies include Paged.js for rendering. ```javascript // resources/scripts/custom.js // Hook into MkDocs Exporter rendering lifecycle window.MkDocsExporter = { // Called before Paged.js starts rendering render: async function(config) { console.log('[mkdocs-exporter] Starting PDF render'); console.log('[mkdocs-exporter] Config:', config); // Access page metadata if (window.__MKDOCS_EXPORTER__) { const metadata = window.__MKDOCS_EXPORTER__; console.log('[mkdocs-exporter] Page:', metadata.page, 'of', metadata.pages); } // Custom preprocessing document.querySelectorAll('code').forEach(el => { el.classList.add('pdf-optimized'); }); // Modify content before PDF generation const tables = document.querySelectorAll('table'); tables.forEach(table => { table.style.fontSize = '10pt'; }); } }; // Listen to Paged.js events if (window.PagedPolyfill) { window.PagedPolyfill.on('afterRendered', (flow) => { console.log('[mkdocs-exporter] PDF rendered successfully'); console.log('[mkdocs-exporter] Total pages:', flow.total); }); } // Custom page numbering or modifications document.addEventListener('DOMContentLoaded', () => { console.log('[mkdocs-exporter] DOM ready, preparing for PDF'); }); ``` -------------------------------- ### Enable PDF Format in MkDocs Configuration Source: https://github.com/adrienbrignon/mkdocs-exporter/blob/master/docs/configuration/generating-pdf-documents.md Enables the PDF format within the MkDocs Exporter plugin configuration. This snippet shows how to set the 'pdf.enabled' option, which can be controlled by an environment variable. ```yaml plugins: - exporter: formats: pdf: enabled: !ENV [MKDOCS_EXPORTER_PDF_ENABLED, true] ``` -------------------------------- ### Hide cover pages for specific pages Source: https://github.com/adrienbrignon/mkdocs-exporter/blob/master/docs/configuration/generating-pdf-documents.md Hides cover pages for individual pages using front matter configuration. Useful for appendixes or supplementary content that shouldn't have cover pages. Only affects the specified page, not the global configuration. ```markdown --- hidden: - covers --- # Appendix A This appendix contains supplementary information but wont have cover pages... ``` -------------------------------- ### Configure PDF aggregation in mkdocs.yml Source: https://github.com/adrienbrignon/mkdocs-exporter/blob/master/docs/configuration/generating-pdf-documents.md Enables the aggregator feature to combine multiple PDF documents into a single file. Configures output filename and cover page handling. Useful for creating comprehensive documentation bundles. ```yaml plugins: - exporter: formats: pdf: aggregator: enabled: true output: documentation.pdf covers: all ``` -------------------------------- ### Enable Explicit PDF Generation Mode Source: https://github.com/adrienbrignon/mkdocs-exporter/blob/master/docs/configuration/generating-pdf-documents.md Configures MkDocs Exporter to require explicit enabling for PDF generation for each page. When 'explicit: true', only pages with `pdf: true` in their front matter will be included. ```yaml plugins: - exporter: formats: pdf: explicit: true ``` -------------------------------- ### Explicitly Enable PDF Generation for a Page Source: https://github.com/adrienbrignon/mkdocs-exporter/blob/master/docs/configuration/generating-pdf-documents.md Front matter to explicitly enable PDF generation for a specific Markdown file. This is used in conjunction with the 'explicit: true' configuration in mkdocs.yml. ```yaml --- pdf: true --- ``` -------------------------------- ### Configure Concurrency for PDF Generation Source: https://github.com/adrienbrignon/mkdocs-exporter/blob/master/docs/configuration/generating-pdf-documents.md Sets the concurrency level for PDF generation, allowing multiple pages to be processed simultaneously. A higher number like 16 can significantly speed up generation for large projects. ```yaml plugins: - exporter: formats: pdf: concurrency: 16 ``` -------------------------------- ### Define Dynamic Button with Python HREF (YAML) Source: https://github.com/adrienbrignon/mkdocs-exporter/blob/master/docs/configuration/adding-buttons-to-pages.md YAML configuration to define a button whose 'href' attribute is dynamically resolved by a Python function. It assumes the function is located in 'my_module.button.href'. ```yaml plugins: - exporter: buttons: - title: Download as PDF icon: material-file-download-outline attributes: href: !!python/name:my_module.button.href ``` -------------------------------- ### Define PDF stylesheet Source: https://github.com/adrienbrignon/mkdocs-exporter/blob/master/docs/configuration/generating-pdf-documents.md SCSS stylesheet for configuring PDF page size and margins. Uses @page rule to set A4 paper size with 1.20cm margins. Applied globally to all generated PDF documents. ```scss @page { size: A4; margin: 1.20cm; } ``` -------------------------------- ### Explicitly Disable PDF Generation for a Page Source: https://github.com/adrienbrignon/mkdocs-exporter/blob/master/docs/configuration/generating-pdf-documents.md Front matter to explicitly disable PDF generation for a specific Markdown file. This is used to exclude pages from the PDF output, even when PDF generation is generally enabled. ```yaml --- pdf: false --- ```