请参考以下代码段:
// Get information of attachments.
Attachments attachments = new Attachments(doc, empty_nametree);
int count = attachments.getCount();
for (int i = 0; i < count; i++) {
String key = attachments.getKey(i);
FileSpec file_spec = attachments.getEmbeddedFile(key);
if (!file_spec.isEmpty()) {
String name = file_spec.getFileName();
if (file_spec.isEmbedded()) {
String export_file_path = output_path + name;
file_spec.exportToFile(export_file_path);
}
}
}