PDFsharp & MigraDoc Foundation
http://forum.pdfsharp.net/

F# Sample Code for PDFsharp
http://forum.pdfsharp.net/viewtopic.php?f=8&t=3422
Page 1 of 1

Author:  thorium [ Sat Aug 13, 2016 10:38 am ]
Post subject:  F# Sample Code for PDFsharp

Feel free to add to Wiki. I would have, but it wasn't public.

Code:
#I @"C:\git\welendus\packages\PdfSharp\lib\net20"
#r "PdfSharp.dll"

open PdfSharp.Pdf
open PdfSharp.Drawing

let filename = "HelloWorld3.pdf"

let generatePdf() =
    use document = new PdfDocument()
    document.Info.Title <- "Created with PDFsharp"
    let page1 = document.AddPage()
    let gfx1 = page1 |> XGraphics.FromPdfPage
    let font = XFont("Verdana", 20., XFontStyle.BoldItalic)

    gfx1.DrawString(
        "Hello, World!", font, XBrushes.Black,
        XRect(0., 0., page1.Width.Value, page1.Height.Value),
        XStringFormats.Center)

    document.Save filename

generatePdf()
System.Diagnostics.Process.Start filename

Author:  () => true [ Sat Aug 13, 2016 1:13 pm ]
Post subject:  Re: F# Sample Code for PDFsharp

Hi!
Thanks for the sample.
thorium wrote:
#I @"C:\git\welendus\packages\PdfSharp\lib\net20"
This line does not look "portable" and needs adjustments. It also needs some external downloads.

The MigraDoc sample uses "open" statements:
viewtopic.php?f=8&t=3195

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/