PDFsharp & MigraDoc Foundation

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

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Sat Aug 13, 2016 10:38 am 
Offline

Joined: Sat Aug 13, 2016 10:35 am
Posts: 2
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


Top
 Profile  
Reply with quote  
PostPosted: Sat Aug 13, 2016 1:13 pm 
Offline
PDFsharp Expert
User avatar

Joined: Wed Dec 09, 2009 8:59 am
Posts: 339
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

_________________
Öhmesh Volta ("() => true")
PDFsharp Team Holiday Substitute


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 4 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