Guide
Obsidian Export to PDF: Custom CSS Guide
Updated July 15, 2026
Obsidian is a powerful note-taking app for managing personal wikis and markdown files, but its built-in PDF export option can feel restrictive. Standard note exports often suffer from poor layouts, default typography, and page splits that cut off tables. Knowing how to set up an obsidian export pdf custom css snippet lets you take full control of your document design and print professional summaries.
By utilizing Obsidian’s native stylesheet snippets, you can override how pages render during export. Here is a step-by-step guide to installing and writing print-specific styling code.
Step 1: Create a CSS Snippet in Obsidian
To write custom CSS that only triggers when exporting a note to PDF, you must create a styling file inside your vault configuration.
- Open Obsidian and head to Settings (gear icon bottom left).
- Go to the Appearance tab.
- Scroll down to the CSS snippets section and click the Folder icon on the right. This opens your vault’s hidden snippet folder:
.obsidian/snippets/. - Inside that folder, create a new text file named
print-styles.css. - Open this file in any text editor (like Notepad, TextEdit, or VS Code).
Step 2: Write Print-Specific CSS Rules
Since you only want these overrides to apply during printing or PDF export (and not while you are writing inside your normal editor theme), wrap your code in an @media print block.
Add the following rules to your print-styles.css file:
@media print {
/* 1. Reset typography and margins */
body, .markdown-preview-view {
font-family: 'Inter', sans-serif;
color: #111111 !important;
background-color: #ffffff !important;
font-size: 11pt;
line-height: 1.6;
}
/* 2. Style page margins and headers */
@page {
size: A4;
margin: 20mm;
}
/* 3. Style code blocks and prevent page break splits */
pre, code {
background-color: #f5f5f5 !important;
border: 1px solid #e0e0e0 !important;
font-size: 9.5pt;
}
pre, blockquote, table, img {
page-break-inside: avoid;
break-inside: avoid;
}
/* 4. Ensure headings don't end up stranded at the bottom of a page */
h1, h2, h3, h4, h5, h6 {
page-break-after: avoid;
break-after: avoid;
color: #000000 !important;
}
/* 5. Force major headers to start on a new page */
.markdown-preview-view h2 {
page-break-before: always;
break-before: page;
}
/* Disable this on the first heading to avoid a blank first page */
.markdown-preview-view h2:first-of-type {
page-break-before: avoid;
break-before: avoid;
}
}
Save the file when you are finished.
Step 3: Enable the Snippet in Obsidian
Once the file is saved, return to your Obsidian Appearance settings panel. Click the Refresh arrow button next to CSS snippets. You will see print-styles appear in the list. Click the toggle switch next to it to activate it vault-wide.
To test your new styles:
- Open the note you want to export.
- Open the command palette (
Ctrl+PorCmd+P). - Type
Export to PDFand press Enter. - Set your configuration and click Export. Your compiled PDF will now display your custom margins, row alignments, and cleaner code blocks.
Troubleshooting Common Obsidian CSS Issues
- Default Theme Overrides: If your custom colors or font styling aren’t rendering, Obsidian’s theme stylesheets might be overriding your snippet. Add the
!importantflag to your selectors (as shown in the code block above) to force priority. - Blank Pages: If your document exports with unexpected blank pages, it is usually because a
break-before: page;orbreak-after: always;property is conflict-splitting small sections. Try removing manual page break selectors and rely onbreak-inside: avoidon tables instead.
Bottom Line
Using Obsidian’s snippet manager is the best way to tailor document designs for recurring reports or personal wikis. If you already manage notes in Obsidian but want to keep writing offline, snippets are a permanent solution. For more details on how these note ecosystems stack up against each other, see our MarkdownToFile vs Obsidian comparison.
If you are looking for an instant, visual editor where you can see page breaks repaginate in real-time as you change themes and margins, try our web-based online editor with zero local configuration.
Written by Markdown to PDF Editorial Team
Our team specializes in document design, web standards, and developer utilities. This guide was researched and vetted against current browser printing standards and Paged.js specifications. Learn more on our About page.
Try it yourself — free, no signup
Convert your Markdown to a polished PDF right in your browser.
Open the editor