Робота з зображеннями
Витягніть зображення з документа OneNote
Усі зображення зберігаються всередині вузлів зображення в документі OneNote.
Витяг зображення
Щоб витягнути всі зображення або з документа OneNote, виконайте ці кроки:
- Використовуйте метод Документ .getChildNodes, щоб вибрати всі вузли зображення.
- itale через отримані колекції вузлів зображення.
- Витягування байт зображення за допомогою властивості Image.bytes.
- Збережіть байти зображення у файл.
Наведений нижче приклад коду демонструє, як витягувати зображення з документа OneNote та зберегти їх як файли.
Get Information of Each Image from the OneNote Document
The Image class provides all the image properties for images in OneNote documents. All the images of the OneNote file are contained by image nodes in the Document object.
Get Information
The code example given below demonstrates how to get information about each image from a OneNote document.
Insert an Image on a OneNote Document Page
Aspose.Diagram for .NET APIs now allows inserting an image anywhere on the OneNote document.
An image can be inserted in the following ways.
Insert an Image in an Existing OneNote Document
To insert an image on a OneNote document, follow these steps:
- Use the Document.FirstChild property to get the first page.
- Use the Image class constructor to load the image.
- Use the Image.Width and Image.Height properties to adjust the size of the image.
- Use the Image.VerticalOffset and Image.HorizontalOffset properties to set the location of the image.
- Use the Page.AppendChild property to insert the image.
- Save a OneNote document.
The code example given below demonstrates how to insert an image on a OneNote document and save them as files.
Build a OneNote Document from Scratch and Insert an Image
Build a OneNote Document from the Scratch and Insert an Image using an Image Stream
This code example shows how to build a new OneNote document and insert an image using the image stream.
Support for Image Alternative Text
Link an Image to Hyperlink
Remove an Image
1var document = new Document("file.one");
2
3var images = document.GetChildNodes<Image>();
4
5foreach (Aspose.Note.Image image in images)
6{
7 if (image.ParentNode == null)
8 {
9 continue;
10 }
11
12 (image.ParentNode as Page)?.RemoveChild(image);
13 // The parent element of the image can be not only the page
14 (image.ParentNode as OutlineElement)?.RemoveChild(image);
15}
16
17document.Save("after.pdf");