How to Convert Your Trilium Notes to PDF (and Unlock Knowledge for LLMs)?
Published on 2025-05-03
Trilium Notes is an incredibly powerful and flexible personal knowledge management tool. Unlike many popular note-taking apps (like Obsidian, Logseq) that primarily use Markdown, Trilium's core is HTML. This means Trilium can store notes with extremely rich formatting and complex structures, far exceeding the expressive capabilities of Markdown—you can easily embed various web elements, use intricate styles, and even add custom JavaScript widgets.
This flexibility is a huge advantage of Trilium, but it also presents a small challenge: What should we do when we want to share notes with others, archive them in a standard format, or—as we'll focus on today—feed the note content into Large Language Models (LLMs) that require specific formats like PDF?
Many LLMs are best optimized for processing PDF documents when handling user uploads. Directly uploading HTML files (especially those containing complex styles and scripts) might prevent the model from correctly parsing the content. Therefore, to enable these powerful AI models to understand and learn from our carefully organized Trilium knowledge base, converting the notes to PDF format becomes a very practical step.
Don't worry, the process isn't complicated. The core idea involves two steps:
- Export notes from Trilium into HTML format.
- Convert the exported HTML file(s) into PDF format.
Let's walk through how to accomplish these two steps.
Why Convert Trilium Notes to PDF? (Especially for LLMs)
While Trilium itself offers powerful search and organization features, converting to PDF becomes particularly important in the following scenarios:
- Compatibility with Large Language Models (LLMs): This is our main focus. Many LLMs (like Anthropic Claude, OpenAI GPT, etc.) parse PDF documents most effectively when processing user-uploaded files. Providing PDF files ensures the model can read your note content more accurately and completely, whether it's for Q&A, summarization, or generating content based on your knowledge base.
- Standardized Archiving: PDF is a universal, cross-platform document format ideal for long-term, reliable archiving of your important notes, ensuring they can still be opened in their original appearance years later.
- Consistent Sharing & Printing: When sharing notes with someone who doesn't use Trilium, PDF guarantees they see the content as you intended on any device. Similarly, PDF offers better format control for printing.
Step 1: Exporting from Trilium Notes to HTML
Trilium provides flexible export functionality. You'll need to choose the appropriate method based on your needs:
- Select the Note(s) to Export: In Trilium's note tree, right-click on the note or note branch (parent note) you wish to export.
- Choose the Export Option: In the context menu, find an option similar to "Export".
- Configure Export Settings:
- Export Format: Select HTML.
- Export Scope (Include...):
- If you only want to export the currently selected note, choose an option like "Only this note".
- If you want to export the note and all its children, select an option like "Note and descendants" or "Note subtree". This is very useful for exporting entire knowledge branches for LLMs.
- Export Type/Output:
- Single HTML file: If Trilium supports packaging all content (including images, possibly embedded via Base64 encoding) into one HTML file, this is the most convenient option for subsequent conversion.
- Multiple HTML files: Exporting as multiple files usually includes a main
index.html
and other sub-pages and resources (like images, CSS files). This method also works but might require handling multiple files or packaging them for conversion. - ZIP archive: This typically bundles multiple HTML files along with related images, CSS, etc., preserving the original file structure. It's also a good choice, especially when notes contain many local images.
- Other Options: Look for options like "Include images", "Include attachments", "Apply theme CSS", etc., and check them as needed. To preserve the original appearance as much as possible, it's recommended to include styles and images.
- Execute Export: Confirm your settings, click the "Export" button, and choose a location to save the file(s).
Important Note: Specific menu names and options might vary slightly depending on your Trilium version. Please refer to the official documentation or UI hints for your current version. It's generally recommended to choose the "Single HTML file" or "ZIP archive" export method, as these usually do a better job of including all necessary content for the next conversion step.
Step 2: Converting the Exported HTML to PDF
Once you have the exported HTML file (or the HTML files extracted from a ZIP archive), there are several ways to convert it to PDF:
Method 1: Using Your Browser's "Print to PDF" Feature (Most Common)
This is the simplest and most direct method, suitable for most situations, especially for single HTML files.
- Open the HTML File in Your Browser: Double-click your HTML file (if it's from a ZIP, first extract it and find the main HTML file, often named
index.html
or similar to your exported root note). It will open in your default browser (e.g., Chrome, Edge, Firefox). - Open the Print Dialog: Press
Ctrl + P
(Windows/Linux) orCmd + P
(Mac). - Select the Destination Printer: In the Destination/Printer dropdown menu, choose "Save as PDF", "Microsoft Print to PDF", or a similar option.
- Adjust Settings (Optional):
- Layout: Choose Portrait or Landscape.
- Margins: You can set them to Default, None, or Custom. "None" might get closer to the original web layout, but sometimes "Default" works better.
- Options/More settings:
- Background graphics: Crucial: Make sure this option is checked! Otherwise, background colors, images, and other styles in your notes will be lost.
- Headers and footers: It's usually best to uncheck this for a cleaner page.
- Save the PDF: Click the "Save" button and choose where to save the PDF file.
Pros: No need to install extra software; quick and convenient. Cons: May not perfectly render layouts for very complex HTML or pages using special CSS/JS; page break control might be suboptimal.
Method 2: Using Local Software or Command-Line Tools (Advanced Users)
For users needing more control or batch processing, local software or command-line tools are options.
- Professional PDF Editing Software: Tools like Adobe Acrobat Pro can often directly open or import HTML and save it as PDF.
- Command-Line Tools: Tools like
wkhtmltopdf
orWeasyPrint
(require installation and configuration) allow precise control over the conversion process via the command line. This requires some technical knowledge.
Tips for Better Trilium Note to PDF Conversion Results
- Simplify Note Structure: If PDF conversion is a frequent need, try to avoid overly complex layouts that rely on special scripts when creating notes.
- Check Trilium Export Options: Ensure necessary CSS styles and images are exported. If images are linked, make sure the links are valid or choose to embed images if the export option supports it.
- Preview and Adjust: Always open the PDF file after conversion to check the result, especially pagination in long notes, image display, and code block formatting. If there are issues, try adjusting browser print settings (like margins or scaling) or use a different conversion method.
- Split Large Notes: If a note is extremely long (e.g., dozens of printed pages), conversion might be difficult or slow. Consider splitting it into several sub-notes in Trilium before exporting and converting them individually, or export a ZIP containing all sub-notes and process accordingly.
Feeding Your Knowledge to LLMs
Once you've successfully converted your Trilium notes into PDF files, you can easily upload them to LLM platforms that support document analysis. Now, you can have the AI answer questions, summarize content, or even generate new material based on your own knowledge base, truly unlocking the potential of your accumulated knowledge!
Conclusion
Trilium Notes offers unparalleled note-taking flexibility with its powerful HTML foundation, but this can pose challenges when PDF format is needed (especially for LLM compatibility). By following a simple two-step process—exporting from Trilium as HTML, then converting the HTML to PDF using browser printing or online tools—you can easily overcome this hurdle. Hopefully, this guide helps you make better use of the valuable knowledge stored in your Trilium Notes and leverage the power of AI to maximize its value!
← Back to Blog List