HI,
i would like to remove an attachment from a document
so i have document
and the i run the next
for(Page page : document)
{
List<AttachedFile> attachments = page.getChildNodes(AttachedFile.class);
for (AttachedFile att: attachments )
{
System.out.println("FileName: " + att.getFileName() + "att - " + att.getExtension());
String ext =att.getExtension();
if (if ext.contains("pdf"))
{
att ??? how can i remove or replace the attachment whit empty one? there is no att.setbyte or replace or something
}
}
@paveln1234,
See the following sample code for your reference.
com.aspose.note.Document document = new com.aspose.note.Document("f:\\files\\file.one");
List<com.aspose.note.Page> pages = document.getChildNodes(com.aspose.note.Page.class);
for(com.aspose.note.Page page:pages) {
List<AttachedFile> attachments = page.getChildNodes(AttachedFile.class);
for (AttachedFile att : attachments) {
System.out.println("FileName: " + att.getFileName() + "att - " + att.getExtension());
String ext = att.getExtension();
if (ext.contains("pdf")) {
com.aspose.note.OutlineElement outlineElement = (com.aspose.note.OutlineElement)att.getParentNode();
outlineElement.removeChild(att);
}
}
}
.....
HI thnak you for your answer,
the problem whit your solution is that we get the next exception if the file Attached inside the page
InnerExceptions":[{“com.aspose.note.Page cannot be cast to com.aspose.note.OutlineElement”:{]
@paveln1234,
Could you please share sample code (runnable) here. Also attach your sample OneNote document. We will check it soon.