Drafts Action Directory

PDF Export

Posted by raigmcclellan, Last updated: 2018-07-04 14:28:44 UTC

I often like to edit my writing using GoodNotes and my Apple Pencil. In order to do this, I need to be able to export a Draft as a PDF. I couldn’t come up with a way to do this natively in Workflow, so I combined a script with this Workflow. You may want to change the fonts or styles. I like large line spacing with room to write.

Install

Steps

  • script

    // Process Markdown to HTML
    var mmd = MultiMarkdown.create();
    var html = mmd.render(draft.content);
    
    // Wrap raw MMD output with HTML template with styles to set base fonts.
    var template = "<html><style>body{font-family:'Avenir Next';font-size:100%;line-height: 3;}</style><body>[[content]]</body></html>"
    var html = template.replace("[[content]]", html);
    
    // Set draft template which can be used by the run workflow action next
    draft.setTemplateTag("script_content", html)
  • runWorkflow

    workflowName
    Blog Post Editor
    waitForResponse
    false

Comments

Actions available in the Action Directory are uploaded by community members. Use appropriate caution reviewing downloaded actions before use.