PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Tue Mar 19, 2024 3:52 am

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Tue Sep 22, 2015 1:54 pm 
Offline
PDFsharp Expert
User avatar

Joined: Sat Mar 14, 2015 10:15 am
Posts: 905
Location: CCAA
Out of curiosity I tried MigraDoc with F#.
I'm an F# noob. The sample may not comply to all F# best practices.

See the C# sample for further information about the MigraDoc routines in use:
http://pdfsharp.net/wiki/MigraDocHelloWorld-sample.ashx

Code:
open MigraDoc.DocumentObjectModel
open MigraDoc.Rendering
open System.Diagnostics

let HelloWorld =
    let document = Document()
    let section = document.AddSection()
    let paragraph = section.AddParagraph("Hello, World!")
    ignore(section.AddParagraph("Hello, World!"))
    paragraph.Format.Font.Bold <- true // Makes the first line bold.
    let renderer = PdfDocumentRenderer(true)
    renderer.Document <- document
    renderer.RenderDocument()
    renderer.PdfDocument.Save("HelloWorld.pdf")
    ignore(Process.Start("HelloWorld.pdf"))
    0 // return an integer exit code

[<EntryPoint>]
let main argv =
    HelloWorld

_________________
Best regards
Thomas
(Freelance Software Developer with several years of MigraDoc/PDFsharp experience)


Top
 Profile  
Reply with quote  
PostPosted: Sat Oct 03, 2015 9:10 pm 
Offline
PDFsharp Expert
User avatar

Joined: Sat Mar 14, 2015 10:15 am
Posts: 905
Location: CCAA
MigraDoc Made EZR also makes the F# sample shorter:

Code:
open MigraDocMadeEZ

let HelloWorld =
    let mez = MigraDocMadeEZR()
    let paragraph = mez.AddParagraph("Hello, World!")
    ignore(mez.AddParagraph("Hello, World!"))
    ignore(paragraph.Bold(true)) // Makes the first line bold.
    mez.MakePdf("HelloWorld.pdf", true)
    0 // return an integer exit code

[<EntryPoint>]
let main argv =
    HelloWorld

_________________
Best regards
Thomas
(Freelance Software Developer with several years of MigraDoc/PDFsharp experience)


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group