Is this javascript code correct?
- Code: Select all
var xmlAttachmentBytes = FileUtil.readBytes(xmlFile.getAbsolutePath());
logger.info("Dimensione di xmlAttachmentBytes: " + xmlAttachmentBytes.length);
var attachment = new com.spire.pdf.attachments.PdfAttachment("cda.xml");
attachment.setData(xmlAttachmentBytes);
attachment.setDescription("cda.xml");
attachment.setMimeType("application/xml");
doc.getAttachments().add(attachment);
When I save the PDFA3:
- Code: Select all
var byteArrayOutputStream = new ByteArrayOutputStream();
doc.saveToStream(byteArrayOutputStream, com.spire.pdf.FileFormat.PDF);
The resulting PDFA3 contain the cda.xml attachment with 2 times the same XML text in it.
I've verified that the cda.xml file to be attached is correct and contain only one XML text.