我创建了一个包含嵌入 pdf 的 pdf,但是当我在 Windows PC 上生成报告时,我可以在 Adobe pdf 阅读器的新选项卡中打开嵌入的 pdf,但是当我在 RedHat PC 上生成相同的报告时,我是单击 Okular 上的操作文本时无法在新选项卡中打开嵌入的 pdf。我使用此代码
String embeddedFileName = "List_installed_packages_in_container_OS.pdf";
String embeddedFileDescription = tc.getTestname().replaceAll(".pdf", "");
File input=new File(reportloc+embeddedFileName);
byte[] embeddedFileContentBytes=FileUtils.readFileToByteArray(input);
PdfFileSpec spec = PdfFileSpec.createEmbeddedFileSpec(pdf, embeddedFileContentBytes, embeddedFileDescription, embeddedFileName, null, null,null, false);
pdf.addFileAttachment("List_installed_packages_in_container_OS.pdf", spec);
PdfFileSpec fs = PdfFileSpec.createExternalFileSpec(pdf, "List_installed_packages_in_container_OS.pdf", true);
PdfAction action = PdfAction.createLaunch(fs,true);
Text text = new Text(" Click here to open the attached document for further reference");
text.setAction(action);
Table vd=new Table(1);
vd.addCell(new Paragraph("Validation Report:").addStyle(normal).setBold());
vd.addCell(new Paragraph(text).addStyle(normal));
document.add(vd);
document.add(new Paragraph("\n"));
而且,如果我将我的 redhat 报告传输到 Windows PC,我将无法在 adobe 中打开嵌入式 pdf,甚至有人可以让我知道原因。