当我打开使用iText示例生成的PDF文档以将视频嵌入PDF文档IText Example Code时,文档显示为空白。
有没有办法在视频播放时显示视频缩略图,因此该文档的读者会有一些线索知道其中有视频
有没有办法插入播放,暂停,停止按钮等来控制播放
视频不适用于所有环境,我只在使用Acrobat阅读器的Windows笔记本电脑上取得了成功。使用Mac和Linux,视频无法播放。此外,当在浏览器内打开PDF时,视频无法播放。是限制还是我遗失了什么?
当我打开生成的PDF并向下滚动到带有视频的页面时,我收到警告 - “禁用功能以避免安全风险” - 是否有办法以不同的方式嵌入视频以避免看到此消息?
答案 0 :(得分:0)
根据Bruno Lowagie的建议,我使用RichMediaAnnotation编写了以下代码。但视频未显示在生成的PDF中。知道我在这里缺少什么吗?
Document document = new Document();
PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("richMedia.pdf"));
document.open();
writer.setPdfVersion(PdfWriter.PDF_VERSION_1_7);
writer.addDeveloperExtension(PdfDeveloperExtension.ADOBE_1_7_EXTENSIONLEVEL3);
RichMediaAnnotation richMedia = new RichMediaAnnotation(writer, new Rectangle(10,10,150,75));
PdfFileSpecification fs = PdfFileSpecification.fileEmbedded(writer, RESOURCE, "VideoPlayer.swf", null);
PdfIndirectReference asset = richMedia.addAsset("VideoPlayer.swf", fs);
RichMediaConfiguration configuration = new RichMediaConfiguration(PdfName.VIDEO);
RichMediaInstance instance = new RichMediaInstance(PdfName.VIDEO);
RichMediaParams vars = new RichMediaParams();
vars.setBinding(PdfName.BACKGROUND);
instance.setAsset(asset);
configuration.addInstance(instance);
PdfIndirectReference configRef = richMedia.addConfiguration(configuration);
RichMediaActivation activation = new RichMediaActivation();
activation.setCondition(PdfName.XA);
RichMediaPresentation presentation = new RichMediaPresentation();
presentation.setPassContextClick(PdfBoolean.PDFFALSE);
presentation.setTransparent(PdfBoolean.PDFFALSE);
presentation.setStyle(PdfName.WINDOWED);
RichMediaWindow window = new RichMediaWindow();
window.setHeight(240, 800, 64);
window.setWidth(320, 800, 64);
presentation.setWindow(window);
presentation.setNavigationPane(PdfBoolean.PDFFALSE);
presentation.setToolbar(PdfBoolean.PDFFALSE);
activation.setPresentation(presentation);
activation.setConfiguration(configRef);
richMedia.setActivation(activation);
PdfAnnotation richMediaAnnotation = richMedia.createAnnotation();
writer.addAnnotation(richMediaAnnotation);
document.close();