Image.Alignment
Contents
[
Hide
]Image.Alignment property
Gets or sets the alignment.
public HorizontalAlignment Alignment { get; set; }
Examples
Shows how to add an image from file to a document with user defined properties.
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Images();
// Load document from the stream.
Document doc = new Document(dataDir + "Aspose.one");
// Get the first page of the document.
Aspose.Note.Page page = doc.FirstChild;
// Load an image from the file.
Aspose.Note.Image image = new Aspose.Note.Image(doc, dataDir + "image.jpg")
{
// Change the image's size according to your needs (optional).
Width = 100,
Height = 100,
// Set the image's location in the page (optional).
HorizontalOffset = 100,
VerticalOffset = 400,
// Set image alignment
Alignment = HorizontalAlignment.Right
};
// Add the image to the page.
page.AppendChildLast(image);
Shows how to add an image from stream to a document.
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Images();
// Create an object of the Document class
Document doc = new Document();
// Initialize Page class object
Aspose.Note.Page page = new Aspose.Note.Page(doc);
Outline outline1 = new Outline(doc);
OutlineElement outlineElem1 = new OutlineElement(doc);
using (FileStream fs = File.OpenRead(dataDir + "image.jpg"))
{
// Load the second image using the image name, extension and stream.
Aspose.Note.Image image1 = new Aspose.Note.Image(doc, "Penguins.jpg", fs)
{
// Set image alignment
Alignment = HorizontalAlignment.Right
};
outlineElem1.AppendChildLast(image1);
}
outline1.AppendChildLast(outlineElem1);
page.AppendChildLast(outline1);
doc.AppendChildLast(page);
// Save OneNote document
dataDir = dataDir + "BuildDocAndInsertImageUsingImageStream_out.one";
doc.Save(dataDir);
Shows how to add an image from file to a document.
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Images();
// Create an object of the Document class
Document doc = new Document();
// Initialize Page class object
Aspose.Note.Page page = new Aspose.Note.Page(doc);
// Initialize Outline class object and set offset properties
Outline outline = new Outline(doc);
// Initialize OutlineElement class object
OutlineElement outlineElem = new OutlineElement(doc);
// Load an image by the file path.
Aspose.Note.Image image = new Aspose.Note.Image(doc, dataDir + "image.jpg")
{
// Set image alignment
Alignment = HorizontalAlignment.Right
};
// Add image
outlineElem.AppendChildLast(image);
// Add outline elements
outline.AppendChildLast(outlineElem);
// Add Outline node
page.AppendChildLast(outline);
// Add Page node
doc.AppendChildLast(page);
// Save OneNote document
dataDir = dataDir + "BuildDocAndInsertImage_out.one";
doc.Save(dataDir);
See Also
- enum HorizontalAlignment
- class Image
- namespace Aspose.Note
- assembly Aspose.Note