Skip to content

Latest commit

 

History

History
33 lines (27 loc) · 1.06 KB

PDFExport.md

File metadata and controls

33 lines (27 loc) · 1.06 KB

PDF Converter

This space script will use pandoc to convert markdown pages to PDFs.

Dependencies:

  • Pandoc is installed and in your path
  • PDF engine required by Pandoc is installed (pdflatex)

Limitations:

  • Exported PDF will only contain things that are directly hardcoded in your markdown. Queries or anything added dynamically by Silverbullet will not be included.
silverbullet.registerCommand({name: "Export: As PDF"}, async () => {
  
  const pageName=await syscall("editor.getCurrentPage")
  const mdFileName=`${pageName}.md`
  const pdfFileName=`${pageName}.pdf`

  await syscall("shell.run","pandoc",
    [
    //"--pdf-engine=pdflatex",
    //"-V",
    //"mainfont='WenQuanYi Micro Hei'",
    mdFileName,
    "-o",
    pdfFileName
    ]
  )
  await syscall("editor.downloadFile",pdfFileName,pdfFileName)
  
  await syscall("editor.flashNotification", "PDF Created!");
});