MigraDoc Sample: Images

Modified on 2009/10/05 18:20 by Stefan Lange — Categorized as: MigraDoc Samples, Samples

<< Previous^UpNext >>
This sample shows how to use images in MigraDoc documents.

PDF Output File

See the PDF file created by this sample: output.pdf (19 kB)

Screen Shots

Here is a sample screen shot:

Hello World with image

Source Code

This snippet shows how to add an image to a MigraDoc document:
/// Creates an absolutely minimalistic document.
static Document CreateDocument()
  // Create a new MigraDoc document
  Document document = new Document();
  // Add a section to the document
  Section section = document.AddSection();
  // Add a paragraph to the section
  Paragraph paragraph = section.AddParagraph();
  // Add some text to the paragraph
  paragraph.AddFormattedText("Hello, World!", TextFormat.Italic);
  return document;