public static void Run() { // ExStart:InsertImage // 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). image.Width = 100; image.Height = 100; // Set the image's location in the page (optional). image.VerticalOffset = 400; image.HorizontalOffset = 100; // Set image alignment image.Alignment = HorizontalAlignment.Right; // Add the image to the page. page.AppendChild(image); // ExEnd:InsertImage Console.WriteLine("\nImage inserted successfully to OneNote document."); }
public static void Run() { // ExStart:AddImageNodeWithTag // ExFor:Image // ExFor:Image.Tags // ExFor:NoteTagCore // ExFor:NoteTagCore.Icon // ExFor:NoteTag // ExFor:Page // ExFor:Outline // ExFor:OutlineElement // ExSummary:Shows how to add new image with tag. // The path to the documents directory. string dataDir = RunExamples.GetDataDir_Tags(); // 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 Outline outline = new Outline(doc); // Initialize OutlineElement class object OutlineElement outlineElem = new OutlineElement(doc); // Load an image Aspose.Note.Image image = new Aspose.Note.Image(doc, dataDir + "icon.jpg"); // Insert image in the document node outlineElem.AppendChildLast(image); image.Tags.Add(new NoteTag { Icon = TagIcon.YellowStar, }); // Add outline element node outline.AppendChildLast(outlineElem); // Add outline node page.AppendChildLast(outline); // Add page node doc.AppendChildLast(page); // Save OneNote document dataDir = dataDir + "AddImageNodeWithTag_out.one"; doc.Save(dataDir); // ExEnd:AddImageNodeWithTag Console.WriteLine("\nImage node with tag added successfully.\nFile saved at " + dataDir); }
public static void Run() { // ExStart:BuildDocAndInsertImage // ExFor:Document // ExFor:Image // ExFor:Image.Alignment // ExSummary: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); // ExEnd:BuildDocAndInsertImage Console.WriteLine("\nDocument created and image inserted successfully.\nFile saved at " + dataDir); }
public static void Run() { // ExStart:BuildDocAndInsertImageUsingImageStream // ExFor:Document // ExFor:Image // ExFor:Image.Alignment // ExSummary: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); // ExEnd:BuildDocAndInsertImageUsingImageStream Console.WriteLine("\nDocument created and image using image stream inserted successfully.\nFile saved at " + dataDir); }
public static void Run() { // ExStart:ImageAlternativeText // The path to the documents directory. string dataDir = RunExamples.GetDataDir_Images(); var document = new Document(); var page = new Page(document); var image = new Aspose.Note.Image(document, dataDir + "image.jpg"); image.AlternativeText = "ImageAlternativeText"; page.AppendChild(image); document.AppendChild(page); dataDir = dataDir + "ImageAlternativeText_out.one"; document.Save(dataDir); // ExEnd:ImageAlternativeText Console.WriteLine("\nImage alternative text setup successfully.\nFile saved at " + dataDir); }
public static void Run() { // ExStart:BuildDocAndInsertImageUsingImageStream // 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) { VerticalOffset = 600, HorizontalOffset = 0 }; OutlineElement outlineElem1 = new OutlineElement(doc); 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 image1.Alignment = HorizontalAlignment.Right; outlineElem1.AppendChild(image1); outline1.AppendChild(outlineElem1); page.AppendChild(outline1); doc.AppendChild(page); dataDir = dataDir + "BuildDocAndInsertImageUsingImageStream_out_.one"; // Save OneNote document doc.Save(dataDir); // ExEnd:BuildDocAndInsertImageUsingImageStream Console.WriteLine("\nDocument created and image using image stream inserted successfully.\nFile saved at " + dataDir); }