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:
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);
section.AddImage("../../SomeImage.png");
return document;
}
Note: The samples on this site usually show and discuss code snippets only. The complete source code of the samples with solutions for Visual Studio is available from the
download area on CodePlex.