docx4j ppt to html,如何使用docx4j添加PPT笔记

这还不够:

slidePart.setPartShortcut(new NotesSlidePart());

您需要通过调用addTargetPart将注释幻灯片部分显式添加到幻灯片部分(以便正确设置关系)。

但是,考虑到pptx格式的工作原理,你还有更多工作要做。要查看所需的部件,请将pptx上传到docx4j webapp。这是我刚才写的代码:

// Now add notes slide.

// 1. Notes master

NotesMasterPart nmp = new NotesMasterPart();

NotesMaster notesmaster = (NotesMaster)XmlUtils.unmarshalString(notesMasterXml, Context.jcPML);

nmp.setJaxbElement(notesmaster);

// .. connect it to /ppt/presentation.xml

Relationship ppRelNmp = pp.addTargetPart(nmp);

/*

*

*/

pp.getJaxbElement().setNotesMasterIdLst(createNotesMasterIdListPlusEntry(ppRelNmp.getId()));

// .. NotesMasterPart typically has a rel to a theme

// .. can we get away without it?

// Nope .. read this in from a file

ThemePart themePart = new ThemePart(new PartName("/ppt/theme/theme2.xml"));

// TODO: read it from a string instead

themePart.unmarshal(

FileUtils.openInputStream(new File(System.getProperty("user.dir") + "/theme2.xml"))

);

nmp.addTargetPart(themePart);

// 2. Notes slide

NotesSlidePart nsp = new NotesSlidePart();

Notes notes = (Notes)XmlUtils.unmarshalString(notesXML, Context.jcPML);

nsp.setJaxbElement(notes);

// .. connect it to the slide

slidePart.addTargetPart(nsp);

// .. it also has a rel to the slide

nsp.addTargetPart(slidePart);

// .. and the slide master

nsp.addTargetPart(nmp);

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值