[{"data":1,"prerenderedAt":764},["ShallowReactive",2],{"guide-markdown-to-pdf-workflow":3},{"id":4,"title":5,"body":6,"date":756,"description":757,"extension":758,"meta":759,"navigation":378,"path":760,"readingTime":111,"seo":761,"stem":762,"__hash__":763},"guides\u002Fguides\u002Fmarkdown-to-pdf-workflow.md","Markdown to PDF Conversion Workflow",{"type":7,"value":8,"toc":750},"minimark",[9,13,18,21,24,54,57,127,130,200,215,218,222,225,260,263,290,293,600,611,614,618,621,628,662,668,678,682,735,738,746],[10,11,12],"p",{},"Turning a Markdown file into a clean, professional PDF is something every developer eventually needs — whether for a project proposal, technical specification, or client deliverable. The challenge is that Markdown has no inherent styling, so the conversion tool you choose determines the quality of the output. This guide covers three reliable approaches, from command-line power tools to browser-based converters.",[14,15,17],"h2",{"id":16},"pandoc-the-universal-converter","Pandoc: The Universal Converter",[10,19,20],{},"Pandoc is the most capable Markdown-to-PDF tool available. It converts Markdown through LaTeX as an intermediate format, which means you get typographic quality on par with academic papers — proper ligatures, justified text, hyphenation, and mathematical typesetting.",[10,22,23],{},"Install Pandoc and a LaTeX distribution (TeX Live on Linux, MacTeX on macOS, or MiKTeX on Windows), then run:",[25,26,31],"pre",{"className":27,"code":28,"language":29,"meta":30,"style":30},"language-bash shiki shiki-themes github-light github-dark","pandoc document.md -o document.pdf\n","bash","",[32,33,34],"code",{"__ignoreMap":30},[35,36,39,43,47,51],"span",{"class":37,"line":38},"line",1,[35,40,42],{"class":41},"sScJk","pandoc",[35,44,46],{"class":45},"sZZnC"," document.md",[35,48,50],{"class":49},"sj4cs"," -o",[35,52,53],{"class":45}," document.pdf\n",[10,55,56],{},"This minimal command produces a serviceable PDF with default styling. For better results, specify a template and metadata:",[25,58,60],{"className":27,"code":59,"language":29,"meta":30,"style":30},"pandoc document.md \\\n  --pdf-engine=xelatex \\\n  --template=mytemplate.tex \\\n  --metadata title=\"Project Specification\" \\\n  -V geometry:margin=1in \\\n  -V fontsize=12pt \\\n  -o document.pdf\n",[32,61,62,71,79,87,98,109,119],{"__ignoreMap":30},[35,63,64,66,68],{"class":37,"line":38},[35,65,42],{"class":41},[35,67,46],{"class":45},[35,69,70],{"class":49}," \\\n",[35,72,74,77],{"class":37,"line":73},2,[35,75,76],{"class":49},"  --pdf-engine=xelatex",[35,78,70],{"class":49},[35,80,82,85],{"class":37,"line":81},3,[35,83,84],{"class":49},"  --template=mytemplate.tex",[35,86,70],{"class":49},[35,88,90,93,96],{"class":37,"line":89},4,[35,91,92],{"class":49},"  --metadata",[35,94,95],{"class":45}," title=\"Project Specification\"",[35,97,70],{"class":49},[35,99,101,104,107],{"class":37,"line":100},5,[35,102,103],{"class":49},"  -V",[35,105,106],{"class":45}," geometry:margin=1in",[35,108,70],{"class":49},[35,110,112,114,117],{"class":37,"line":111},6,[35,113,103],{"class":49},[35,115,116],{"class":45}," fontsize=12pt",[35,118,70],{"class":49},[35,120,122,125],{"class":37,"line":121},7,[35,123,124],{"class":49},"  -o",[35,126,53],{"class":45},[10,128,129],{},"Key options worth knowing:",[131,132,133,146],"table",{},[134,135,136],"thead",{},[137,138,139,143],"tr",{},[140,141,142],"th",{},"Flag",[140,144,145],{},"Purpose",[147,148,149,160,170,180,190],"tbody",{},[137,150,151,157],{},[152,153,154],"td",{},[32,155,156],{},"--pdf-engine=xelatex",[152,158,159],{},"Supports Unicode and custom fonts",[137,161,162,167],{},[152,163,164],{},[32,165,166],{},"-V geometry:margin=1in",[152,168,169],{},"Sets page margins",[137,171,172,177],{},[152,173,174],{},[32,175,176],{},"--toc",[152,178,179],{},"Generates a table of contents",[137,181,182,187],{},[152,183,184],{},[32,185,186],{},"--_highlight-style=pygments",[152,188,189],{},"Code syntax highlighting theme",[137,191,192,197],{},[152,193,194],{},[32,195,196],{},"--css=style.css",[152,198,199],{},"Applies CSS styling (with WeasyPrint engine)",[10,201,202,203,206,207,210,211,214],{},"Pandoc also supports YAML front matter in your Markdown files, pulling ",[32,204,205],{},"title",", ",[32,208,209],{},"author",", and ",[32,212,213],{},"date"," into the PDF header automatically.",[10,216,217],{},"The main drawback of Pandoc is the LaTeX dependency. A full TeX Live installation is several gigabytes, and LaTeX errors can be cryptic. If you only need simple documents, the lighter alternatives below may save you time.",[14,219,221],{"id":220},"weasyprint-html-and-css-pipeline","WeasyPrint: HTML and CSS Pipeline",[10,223,224],{},"WeasyPrint takes a different approach: it converts Markdown to HTML first, then renders the HTML to PDF using CSS for styling. This pipeline is ideal if you already have CSS stylesheets for your documentation and want the PDF to match your web output.",[25,226,228],{"className":27,"code":227,"language":29,"meta":30,"style":30},"pandoc document.md -t html5 --standalone -o document.html\nweasyprint document.html document.pdf\n",[32,229,230,250],{"__ignoreMap":30},[35,231,232,234,236,239,242,245,247],{"class":37,"line":38},[35,233,42],{"class":41},[35,235,46],{"class":45},[35,237,238],{"class":49}," -t",[35,240,241],{"class":45}," html5",[35,243,244],{"class":49}," --standalone",[35,246,50],{"class":49},[35,248,249],{"class":45}," document.html\n",[35,251,252,255,258],{"class":37,"line":73},[35,253,254],{"class":41},"weasyprint",[35,256,257],{"class":45}," document.html",[35,259,53],{"class":45},[10,261,262],{},"Or chain them in one step:",[25,264,266],{"className":27,"code":265,"language":29,"meta":30,"style":30},"pandoc document.md -t html5 | weasyprint - document.pdf\n",[32,267,268],{"__ignoreMap":30},[35,269,270,272,274,276,278,282,285,288],{"class":37,"line":38},[35,271,42],{"class":41},[35,273,46],{"class":45},[35,275,238],{"class":49},[35,277,241],{"class":45},[35,279,281],{"class":280},"szBVR"," |",[35,283,284],{"class":41}," weasyprint",[35,286,287],{"class":45}," -",[35,289,53],{"class":45},[10,291,292],{},"The CSS-driven approach gives you precise control over the visual output:",[25,294,298],{"className":295,"code":296,"language":297,"meta":30,"style":30},"language-css shiki shiki-themes github-light github-dark","@page {\n  size: A4;\n  margin: 2cm;\n  @bottom-center {\n    content: counter(page);\n  }\n}\n\nbody {\n  font-family: \"Inter\", sans-serif;\n  line-height: 1.6;\n  color: #1a1a1a;\n}\n\nh1 { font-size: 24pt; margin-bottom: 12pt; }\nh2 { font-size: 18pt; border-bottom: 1px solid #ccc; }\ncode { background: #f5f5f5; padding: 2px 4px; font-size: 9pt; }\npre code { display: block; padding: 12pt; overflow-wrap: break-word; }\n","css",[32,299,300,309,317,334,344,363,368,373,380,389,407,420,433,438,443,479,516,560],{"__ignoreMap":30},[35,301,302,305],{"class":37,"line":38},[35,303,304],{"class":280},"@page",[35,306,308],{"class":307},"sVt8B"," {\n",[35,310,311,314],{"class":37,"line":73},[35,312,313],{"class":49},"  size",[35,315,316],{"class":307},": A4;\n",[35,318,319,322,325,328,331],{"class":37,"line":81},[35,320,321],{"class":49},"  margin",[35,323,324],{"class":307},": ",[35,326,327],{"class":49},"2",[35,329,330],{"class":280},"cm",[35,332,333],{"class":307},";\n",[35,335,336,339,342],{"class":37,"line":89},[35,337,338],{"class":307},"  @",[35,340,341],{"class":49},"bottom-center",[35,343,308],{"class":307},[35,345,346,349,351,354,357,360],{"class":37,"line":100},[35,347,348],{"class":49},"    content",[35,350,324],{"class":307},[35,352,353],{"class":49},"counter",[35,355,356],{"class":307},"(",[35,358,359],{"class":49},"page",[35,361,362],{"class":307},");\n",[35,364,365],{"class":37,"line":111},[35,366,367],{"class":307},"  }\n",[35,369,370],{"class":37,"line":121},[35,371,372],{"class":307},"}\n",[35,374,376],{"class":37,"line":375},8,[35,377,379],{"emptyLinePlaceholder":378},true,"\n",[35,381,383,387],{"class":37,"line":382},9,[35,384,386],{"class":385},"s9eBZ","body",[35,388,308],{"class":307},[35,390,392,395,397,400,402,405],{"class":37,"line":391},10,[35,393,394],{"class":49},"  font-family",[35,396,324],{"class":307},[35,398,399],{"class":45},"\"Inter\"",[35,401,206],{"class":307},[35,403,404],{"class":49},"sans-serif",[35,406,333],{"class":307},[35,408,410,413,415,418],{"class":37,"line":409},11,[35,411,412],{"class":49},"  line-height",[35,414,324],{"class":307},[35,416,417],{"class":49},"1.6",[35,419,333],{"class":307},[35,421,423,426,428,431],{"class":37,"line":422},12,[35,424,425],{"class":49},"  color",[35,427,324],{"class":307},[35,429,430],{"class":49},"#1a1a1a",[35,432,333],{"class":307},[35,434,436],{"class":37,"line":435},13,[35,437,372],{"class":307},[35,439,441],{"class":37,"line":440},14,[35,442,379],{"emptyLinePlaceholder":378},[35,444,446,449,452,455,457,460,463,466,469,471,474,476],{"class":37,"line":445},15,[35,447,448],{"class":385},"h1",[35,450,451],{"class":307}," { ",[35,453,454],{"class":49},"font-size",[35,456,324],{"class":307},[35,458,459],{"class":49},"24",[35,461,462],{"class":280},"pt",[35,464,465],{"class":307},"; ",[35,467,468],{"class":49},"margin-bottom",[35,470,324],{"class":307},[35,472,473],{"class":49},"12",[35,475,462],{"class":280},[35,477,478],{"class":307},"; }\n",[35,480,482,484,486,488,490,493,495,497,500,502,505,508,511,514],{"class":37,"line":481},16,[35,483,14],{"class":385},[35,485,451],{"class":307},[35,487,454],{"class":49},[35,489,324],{"class":307},[35,491,492],{"class":49},"18",[35,494,462],{"class":280},[35,496,465],{"class":307},[35,498,499],{"class":49},"border-bottom",[35,501,324],{"class":307},[35,503,504],{"class":49},"1",[35,506,507],{"class":280},"px",[35,509,510],{"class":49}," solid",[35,512,513],{"class":49}," #ccc",[35,515,478],{"class":307},[35,517,519,521,523,526,528,531,533,536,538,540,542,545,547,549,551,553,556,558],{"class":37,"line":518},17,[35,520,32],{"class":385},[35,522,451],{"class":307},[35,524,525],{"class":49},"background",[35,527,324],{"class":307},[35,529,530],{"class":49},"#f5f5f5",[35,532,465],{"class":307},[35,534,535],{"class":49},"padding",[35,537,324],{"class":307},[35,539,327],{"class":49},[35,541,507],{"class":280},[35,543,544],{"class":49}," 4",[35,546,507],{"class":280},[35,548,465],{"class":307},[35,550,454],{"class":49},[35,552,324],{"class":307},[35,554,555],{"class":49},"9",[35,557,462],{"class":280},[35,559,478],{"class":307},[35,561,563,565,568,570,573,575,578,580,582,584,586,588,590,593,595,598],{"class":37,"line":562},18,[35,564,25],{"class":385},[35,566,567],{"class":385}," code",[35,569,451],{"class":307},[35,571,572],{"class":49},"display",[35,574,324],{"class":307},[35,576,577],{"class":49},"block",[35,579,465],{"class":307},[35,581,535],{"class":49},[35,583,324],{"class":307},[35,585,473],{"class":49},[35,587,462],{"class":280},[35,589,465],{"class":307},[35,591,592],{"class":49},"overflow-wrap",[35,594,324],{"class":307},[35,596,597],{"class":49},"break-word",[35,599,478],{"class":307},[10,601,602,603,606,607,610],{},"WeasyPrint handles page breaks better than most browser-based solutions. You can use ",[32,604,605],{},"page-break-before: always"," on headings or ",[32,608,609],{},"page-break-inside: avoid"," on tables and code blocks to keep related content together.",[10,612,613],{},"The limitation is that WeasyPrint's CSS support, while solid for print media, does not match a full browser engine. Complex flexbox layouts and certain CSS grid configurations may render differently than expected.",[14,615,617],{"id":616},"online-converters-and-browser-based-workflows","Online Converters and Browser-Based Workflows",[10,619,620],{},"When installing command-line tools is not an option, several online services and browser workflows produce acceptable results.",[10,622,623,627],{},[624,625,626],"strong",{},"Markdown to HTML first",": Convert your Markdown to styled HTML, then use your browser's built-in print-to-PDF function. This gives you the browser's full rendering engine, which handles CSS correctly. The downside is limited control over page breaks and headers.",[25,629,631],{"className":27,"code":630,"language":29,"meta":30,"style":30},"# Generate standalone HTML with embedded styles\npandoc document.md --standalone --css=style.css --self-contained -o document.html\n# Open in browser, then Ctrl+P → Save as PDF\n",[32,632,633,639,657],{"__ignoreMap":30},[35,634,635],{"class":37,"line":38},[35,636,638],{"class":637},"sJ8bj","# Generate standalone HTML with embedded styles\n",[35,640,641,643,645,647,650,653,655],{"class":37,"line":73},[35,642,42],{"class":41},[35,644,46],{"class":45},[35,646,244],{"class":49},[35,648,649],{"class":49}," --css=style.css",[35,651,652],{"class":49}," --self-contained",[35,654,50],{"class":49},[35,656,249],{"class":45},[35,658,659],{"class":37,"line":81},[35,660,661],{"class":637},"# Open in browser, then Ctrl+P → Save as PDF\n",[10,663,664,667],{},[624,665,666],{},"Dedicated online tools",": Services like md2pdf, MarkdowntoPDF, and CloudConvert accept Markdown uploads and return styled PDFs. These are convenient for one-off conversions but may not handle custom CSS, complex tables, or math notation reliably.",[10,669,670,673,674,677],{},[624,671,672],{},"VS Code workflow",": The \"Markdown PDF\" extension for VS Code converts ",[32,675,676],{},".md"," files to PDF directly from the editor. It uses Chrome's rendering engine under the hood, so the output matches what you see in the Markdown preview pane. Configuration options let you set margins, orientation, and header\u002Ffooter content.",[14,679,681],{"id":680},"choosing-the-right-tool","Choosing the Right Tool",[131,683,684,694],{},[134,685,686],{},[137,687,688,691],{},[140,689,690],{},"Need",[140,692,693],{},"Best Tool",[147,695,696,704,712,720,728],{},[137,697,698,701],{},[152,699,700],{},"Academic or typographic quality",[152,702,703],{},"Pandoc + XeLaTeX",[137,705,706,709],{},[152,707,708],{},"Match existing web documentation styles",[152,710,711],{},"WeasyPrint",[137,713,714,717],{},[152,715,716],{},"Quick one-off conversion",[152,718,719],{},"Browser print or online tool",[137,721,722,725],{},[152,723,724],{},"Batch processing many files",[152,726,727],{},"Pandoc shell script",[137,729,730,733],{},[152,731,732],{},"Math equations in Markdown",[152,734,703],{},[10,736,737],{},"Regardless of which tool you choose, always proof the PDF output. Conversion artifacts — missing images from relative paths, broken table layouts, or code overflowing margins — are common and only visible in the final rendering.",[10,739,740,741,745],{},"For a quick preview of how your Markdown renders before converting to PDF, use the live preview tool at ",[742,743,744],"a",{"href":744},"\u002Ftools\u002Fmarkdown-preview",". It shows rendered output in real time so you can fix formatting issues before committing to a PDF export.",[747,748,749],"style",{},"html pre.shiki code .sScJk, html code.shiki .sScJk{--shiki-default:#6F42C1;--shiki-dark:#B392F0}html pre.shiki code .sZZnC, html code.shiki .sZZnC{--shiki-default:#032F62;--shiki-dark:#9ECBFF}html pre.shiki code .sj4cs, html code.shiki .sj4cs{--shiki-default:#005CC5;--shiki-dark:#79B8FF}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .szBVR, html code.shiki .szBVR{--shiki-default:#D73A49;--shiki-dark:#F97583}html pre.shiki code .sVt8B, html code.shiki .sVt8B{--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .s9eBZ, html code.shiki .s9eBZ{--shiki-default:#22863A;--shiki-dark:#85E89D}html pre.shiki code .sJ8bj, html code.shiki .sJ8bj{--shiki-default:#6A737D;--shiki-dark:#6A737D}",{"title":30,"searchDepth":73,"depth":73,"links":751},[752,753,754,755],{"id":16,"depth":73,"text":17},{"id":220,"depth":73,"text":221},{"id":616,"depth":73,"text":617},{"id":680,"depth":73,"text":681},"2026-05-28","Convert Markdown documents to polished PDFs using Pandoc, WeasyPrint, and online tools.","md",{},"\u002Fguides\u002Fmarkdown-to-pdf-workflow",{"title":5,"description":757},"guides\u002Fmarkdown-to-pdf-workflow","KRoLu3BhWhyaPLuClp5v4mdknBusH4IWOO-HTgzo1y8",1780401335228]