Please elaborate on this statement. What is your ultimate goal? Are you trying to integrate ONLYOFFICE Docs (Document Server) with your app to enhance it with capability of running editor inside of your app or you wish to utilize Document Builder to generate documents without running the editor in your app?
It is important to keep in mind and Document Server and stand-alone Document Builder are different apps, so the integration process will differ, depending in the desired goal.
To clarify: I’ve already integrated the OnlyOffice Docs editor into the front end of my application. What I’m aiming to do now is use Document Builder on the backend to perform mail merge operations, inject variables, and then retrieve the final document as a buffer—without writing it to disk at any point (not even temporarily).
My use case:
I have a DOCX template that includes merge fields (like {{date}}, {{section_content}}, etc.).
I also have another DOCX file whose content should replace a specific merge field (e.g., {{section_content}}).
In addition to that, I need to fill other fields like the date and recipient name.
Once the merge is complete, I need the output as a byte buffer so I can store it directly in the database or serve it through an API—no local file writing involved.
What I’ve considered:
Extract the content of the secondary DOCX using ToJson.
Store that JSON in memory.
Load the main template.
Replace the target merge field with the JSON content, and fill in the rest of the fields.
Retrieve the final merged document as a buffer or stream.
Does this seem like the right approach? And if there’s a better way to achieve this kind of in-memory transformation using Document Builder, I’d be grateful for your guidance.
Firstly, Document Builder is also packaged as Web API service of Document Server. Please refer to the following documentation:
Basically, you can utilize it instead of stand-alone version.
Secondly, please elaborate on this goal:
Do I understand correctly that you do not want to actually modify the contents of any files? Generally speaking, you would like to get some necessary information from file 1, apply it to the file 2 and then save contents of the file 2 as, for instance, a string, but do not save those applied changes, is that right?
I have to note right there that Document Builder, either web one or stand alone, can only save documents in documents formats (DOCX, PDF, ODT, etc.).