Cake addin to convert markdown files to pdf
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.

README.md

Cake.MarkdownToPdf

Build status NuGet Version License

Cake addin to convert markdown files to pdf. This addin uses Markdig markdown processor.

Usage

Directly in your build script via a Cake #addin directive:

#addin "Cake.MarkdownToPdf"

Task("Convert")
  .Does(() => {        
    MarkdownFileToPdf("readme.md", "output.pdf");
    
    // or markdown text
    MarkdownToPdf("Some markdown formated text...", "output.pdf");
    
    // or using settings
    MarkdownFileToPdf("readme.md", "output.pdf", settings => {
        settings.Theme = Themes.Github;
        settings.UseAdvancedMarkdownTables(); // or UseAdvancedMarkdownExtensions();
        
        // accessing the internal markdig markdown pipeline
        settings.MarkdownPipeline.UseGridTables();
    });
});

Themes

Use can use the build-in "Default" or "Github" theme or define any css style on your own

Task("Convert")
  .Does(() => {        
    // custom css
    MarkdownFileToPdf("readme.md", "output.pdf", settings => {
        settings.CssFile = "path to my css";
        
        // optional
        settings.HtmlTemplateFile = "path to my custom html file"; // using {$html} placeholder
    });
});

PDF settings

Settings such as orientation, margins etc can be set through the PdfSettings:

Task("Convert")
  .Does(() => {        
  
    MarkdownFileToPdf("readme.md", "output.pdf", settings => {
        settings.Pdf.PageSize = PdfPageSize.Letter;
    });
});