Coder Social home page Coder Social logo

fsharp.markdown.pdf's Introduction

FSharp.Markdown.Pdf

PDF formatting from FSharp.Markdown (part of the F# Formatting project).

Nuget

NuGet package

F# Examples

From F#, you can use the Markdown.TransformPdf and Markdown.WritePdf extension methods:

    open FSharp.Markdown
    open FSharp.Markdown.Pdf

    let text = """Some text in Mardown format..."""
    
    // formatting to PDF and save result to file
    Markdown.TransformPdf(text, @"C:\temp\markdown.pdf")
    
    // formatting to PDF and save result to stream
    use stream = File.OpenWrite(@"C:\temp\markdown2.pdf")
    Markdown.TransformPdf(text, stream)
    
    let parsed = Markdown.Parse(text)
    
    // taking a tokenized Markdown document and formatting to PDF
    // before saving result to file
    Markdown.WritePdf(parsed, @"C:\temp\markdown3.pdf")
    
    // taking a tokenized Markdown document and formatting to PDF
    // before saving result to stream
    use stream' = File.OpenWrite(@"C:\temp\markdown4.pdf")
    Markdown.WritePdf(parsed, stream')

C# Examples

The Markdown.TransformPdf and Markdown.WritePdf extensions methods are not visible to C# due to the way F# extension methods defined with the type XYZ with syntax are compiled, so in its place, there is a MarkdownPdf type which you can use from C#:

    using FSharp.Markdown;
    using FSharp.Markdown.Pdf;
    
    var text = "Some text in Markdown format...";
    
    // formatting to PDF and save result to file
    MarkdownPdf.Transform(text, @"C:\temp\markdown.pdf");
    
    // formatting to PDF and save result to stream
    using (var stream = File.OpenWrite(@"C:\temp\markdown2.pdf"))
    {
        MarkdownPdf.Transform(text, stream);
    }
    
    var parsed = Markdown.Parse(text);
    
    // taking a tokenized Markdown document and formatting to PDF
    // before saving result to file
    MarkdownPdf.Write(parsed, @"C:\temp\markdown3.pdf");
    
    // taking a tokenized Markdown document and formatting to PDF
    // before saving result to stream
    using (var stream2 = File.OpenWrite(@"C:\temp\markdown4.pdf"))
    {
        MarkdownPdf.Write(parsed, stream2);
    }

fsharp.markdown.pdf's People

Contributors

theburningmonk avatar julianrendell avatar bitdeli-chef avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.