我创建了一个 swf 文件,它将在一些外部文件(5 个 mp3 文件、2 个 xml 文件和 6 个图像文件)的帮助下运行。当我使用 itext 创建 pdf 时,我只能单独嵌入 swf 文件。应该如何能够添加这些外部文件来运行 swf。如果您提供一些样本会很有帮助。你能帮我在哪里添加图像、mp3 和 xml 文件以运行 swf 的值。
我的代码如下:
PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("welcome.pdf"));
writer.setPdfVersion(PdfWriter.PDF_VERSION_1_7);
writer.addDeveloperExtension(PdfDeveloperExtension.ADOBE_1_7_EXTENSIONLEVEL3);
document.open();
RichMediaAnnotation richMedia = new RichMediaAnnotation(writer, new Rectangle(36, 400, 559,806));
PdfFileSpecification fs = PdfFileSpecification.fileEmbedded(writer, "ballon.swf", "ballon.swf", null);
PdfIndirectReference asset = richMedia.addAsset("ballon.swf", fs);
RichMediaConfiguration configuration = new RichMediaConfiguration(PdfName.FLASH);
RichMediaInstance instance = new RichMediaInstance(PdfName.FLASH);
RichMediaParams flashVars = new RichMediaParams();
String vars = new String("&day=2011-10-13");
flashVars.setFlashVars(vars);
instance.setParams(flashVars);
instance.setAsset(asset);
configuration.addInstance(instance);
PdfIndirectReference configurationRef = richMedia.addConfiguration(configuration);
RichMediaActivation activation = new RichMediaActivation();
activation.setConfiguration(configurationRef);
richMedia.setActivation(activation);
PdfAnnotation richMediaAnnotation = richMedia.createAnnotation();
richMediaAnnotation.setFlags(PdfAnnotation.FLAGS_PRINT);
writer.addAnnotation(richMediaAnnotation);
document.close();