Converting attachments in an IDocument from "reference mode" to "embedded mode" in the backend

Hey,

in our project we use attachments in reference mode and need to use the A12 PrintEngine to generate PDFs. The PrintEngine can only really handle attachments in embedded mode. Switching the project completely to embedded mode is no option.

So we need to find a way in the backend to convert the attachments in an IDocument object from referenced to embedded for the PDF creation step.

Is there already some functionality / util function for something like this in A12 that could help us? Or would we need to implement a solution for ourselves?

Hi @tim-steep-bit ,

DS is handling only reference mode attachments because there is additional logic needed for handling them. Therefore there is no A12 solution but to create IDocument instances with embedded attachments you need to:

  1. load the attachment from the AttachmentService from the reference in the document
  2. base64 encode the content
  3. store the content in the same attachment group

I hope that helped at least a bit

Answer is valid for DS versions 34.2.0 - 36.0.0

This solved the problem. For anyone needing to do the same in the future:

The field instance content in the attachment need to be set with data:<mimeType>;base64,<base64 encoded attachment>