Aspose.Notes 22.1.0 Failed to keep original image size

I have a one note sample where I tried to extract image from One Note, write it to a file, then construct a new Image object to take in that written file and append back to one note file and save the document. I found that image before and after vary vastly on its’ size.

Here is a snippet of my code:
Document doc = new Document(file);
var images = doc.GetChildNodes();
foreach(Image image in images)
{
if(image.ParentNode is Page)
{
page = image.ParentNode as Page;
using(var outStream = new FileStream(imageFile, FileMode.Create, FileAccess.ReadWrite, FileShare.Read))
outStream.Write(image.Bytes, 0, image.Bytes.Length);
var newImage = new Image(imageFile)
{
Height = image.Height,
Width = image.Width,
HorizontalOffset = image.HorizontalOffset,
VerticalOffset = image.VerticalOffset,
Alignment = image.Alignment,
AlternativeTextDescription = image.AlternativeTextDescription,
AlternativeTextTitle = image.AlternativeTextTitle,
IsBackground = image.IsBackground,
HyperlinkUrl = image.HyperlinkUrl
};
page.AppendChildFirst(newImage);
page.RemoveChild(image);
}
else if(image.ParentNode is OutlineElement)
{
outline = image.ParentNode as OutlineElement;
using(var outStream = new FileStream(imageFile, FileMode.Create, FileAccess.ReadWrite, FileShare.Read))
outStream.Write(image.Bytes, 0, image.Bytes.Length);
var newImage = new Image(imageFile)
{
Height = image.Height,
Width = image.Width,
HorizontalOffset = image.HorizontalOffset,
VerticalOffset = image.VerticalOffset,
Alignment = image.Alignment,
AlternativeTextDescription = image.AlternativeTextDescription,
AlternativeTextTitle = image.AlternativeTextTitle,
IsBackground = image.IsBackground,
HyperlinkUrl = image.HyperlinkUrl
};
outline.AppendChildFirst(newImage);
outline.RemoveChild(image);
}
}

Sample: mixed_objects.zip - Google Drive

@dunghnguyen,

Thanks for the sample One Note document.

Please try our latest version/fix: Aspose.Note for .NET v23.2 (Releases | NuGet). If you still find the issue, kindly do provide a standalone sample console application (source files without compilation errors) with all the resource file(s) using Aspose.Note for .NET v23.2. We will check your issue soon.

Hello @amjad.sahi, I’ve tried with Aspose.Note for .NET v23.2.0 but the issue persists.
Please get the source code here: AsposeNoteTest.zip - Google Drive

For safety purposes, I have removed the license file.
The source above also includes my sample onenote file.

@dunghnguyen,

We reproduced the issue after an initial test using your sample project with your sample OneNote document and sample image. We found Aspose.Note could not keep the original image size when replacing in One Note file. We need to investigate your issue in details.

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): NOTENET-5754

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

@dunghnguyen,

We are pleased to inform you that your issue (logged earlier as “NOTENET-5754”) has been resolved. The fix will be included in an upcoming release (Aspose.Note for .NET v23.8) that we plan to release in this month (August). You will be notified when the new version is released.

The issues you have found earlier (filed as NOTENET-5754) have been fixed in this update. This message was posted using Bugs notification tool by senua.remizova

1 Like