Spot the web RSS 2.0
# Saturday, December 15, 2007

PDFsharp is the Open Source library that easily creates PDF documents from any .NET language.

The same drawing routines can be used to create PDF documents, draw on the screen, or send output to any printer.

Here are just a few highlights:

  • Creates PDF documents on the fly from any .Net language
  • Easy to understand object model to compose documents
  • One source code for drawing on a PDF page as well as in a window or on the printer
  • Modify, merge, and split existing PDF files
  • Images with transparency (color mask, monochrome mask, alpha mask)
  • Newly designed from scratch and written entirely in C#
  • The graphical classes go well with .Net
  • Includes MigraDoc Lite for high level text layouting (you can use both PDFsharp and MigraDoc Lite in one document)

Hello World Sample

This sample shows how to create a PDF document, add a page, draw some text, and save it to disk.

// Create a new PDF document
PdfDocument document = new PdfDocument();
 
// Create an empty page
PdfPage page = document.AddPage();
 
// Get an XGraphics object for drawing
XGraphics gfx = XGraphics.FromPdfPage(page);
 
// Create a font
XFont font = new XFont("Verdana", 20, XFontStyle.Bold);
 
// Draw the text
gfx.DrawString("Hello, World!", font, XBrushes.Black,
  new XRect(0, 0, page.Width, page.Height),
  XStringFormat.Center);
 
// Save the document...
string filename = "HelloWorld.pdf";
document.Save(filename);
// ...and start a viewer.
Process.Start(filename);
The result is this:
HelloWorld.pdf (2.41 KB)

Saturday, December 15, 2007 10:59:35 AM (Jerusalem Standard Time, UTC+02:00)  #    Comments [0] - Trackback
.Net | Programming
Navigation
Archive
<December 2007>
SunMonTueWedThuFriSat
2526272829301
2345678
9101112131415
16171819202122
23242526272829
303112345
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2010
Guy Levin
Sign In
Statistics
Total Posts: 63
This Year: 0
This Month: 0
This Week: 0
Comments: 14
Themes
All Content © 2010, Guy Levin