이미지 작업
OneNote 문서에서 이미지 추출
모든 이미지는 OneNote 문서의 이미지 노드 내부에 저장됩니다.
이미지 추출
모든 이미지를 추출하거나 OneNote 문서에서 다음 단계를 따르십시오.
- document .getchildnodes 메소드를 사용하여 모든 이미지 노드를 선택하십시오.
- 결과 이미지 노드 컬렉션을 통해 반복.
- 이미지를 사용하여 이미지 바이트 바이트 배열을 추출합니다.
- 파일에 이미지 바이트를 저장합니다.
아래에 주어진 코드 예제는 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");