Can't see attachments in OneNote documents

Were trying to go through OneNote documents and extract their text and sub documents. Below is a piece of code were using to iterate over these but we don’t seem to be getting all attachments.


This is just sudocode showing the api’s were using.
for (Page page: getDocument().getChildren())
{
for (IPageChildNode childNode: page.getChildren())
{
if (childNode instanceof Image)
{
data = ((Image)childNode).getBytes();
}
else if (childNode instanceof AttachedFile)
{
data = ((AttachedFile)childNode).getBytes();
}
else if (childNode instanceof Outline)
{
// Ignore these, we get their text elsewhere.
return null;
}
else
{
throw new UnsupportedOperationException(“Unknown chileNode type”);
}
}
}
We would expect to see the following items, but we only see “Form I-9.pdf”, and “Donald Semelsberger - Memorial Service Program.docx”. Am I doing something wrong and need to use the API differently?

Regards
Nick

Hi Nick,


Thank you for posting your inquiry.

I have tested this with the following sample code and it lists all the children of a page without any issue. Please try it at your end and let us know your feedback if you face any issue.

Sample Code

Document oneFile = new Document(“829895\Helen’s OneNote with XLS email attachment.one”);

List pages = oneFile.getChildNodes(Page.class);

System.out.println(pages.size());

for(Page page:pages) {
// Get list of attachments
List attachments = page.getChildNodes(AttachedFile.class);
System.out.println("Total attachments: " + attachments.size());

for (AttachedFile a : attachments) {

System.out.println(a.getFileName());
}
}

Thank you. Those methods for extracting all attachments worked.

Hi Nick,


You are welcome and please feel free to write to us if you have any further query in this regard.

Hi,


We have come across a sample document that we don’t seem to be getting any pages from even though it has one. I’ve been using the code suggested above and we get nothing.

Can you take a look at the file and see if you can see anything.

Regards
Nick

Hi Nick,


We were able to reproduce the issue at our end with the available version of Aspose.Note for Java and have logged it as NOTEJAVA-250 for further investigation by our Product team. We’ll update you here once there is some information or a fix version available in this regard.

The issues you have found earlier (filed as ) have been fixed in this Aspose.Words for JasperReports 18.3 update.

The issues you have found earlier (filed as NOTEJAVA-250) have been fixed in Aspose.Note for Java v19.11. This message was posted using Bugs notification tool by ahsaniqbalsidiqui