Download current document outside the iframe of OnlyOffice

I used Reactjs to display content of document, I know we can perform download that document just by clicking the File tab, selecting the download option. However, I wanna create a button to download that document directly. Can someone please guide me about that ?

Hello,
You are referring to Docs Editor, right?
You can use this Command Service method to save the current version of the edited document without closing it: Command service - ONLYOFFICE Api Documentation. You can link function sending the forcesave request to your custom button. Here you can learn more about the logic of forcesave: Saving File - ONLYOFFICE Api Documentation. You can monitor the status 6 message sent to the callback and add your own events that would be triggered each time the saving occurs.
But placing the button outside Editor frame would require Automation API: Automation API - ONLYOFFICE Api Documentation

Okay, I got it. But could you please provide more details about the download feature in Automation API, I wanna do some sample test before purchase a license. Addtionally, outside the Editor frame, I would like to get the edited file to send back to my own server. Can i do that ?

Automation API is not about download feature but rather about generally being able to access Editor’s content from outside Editor frame (from another application) and vice-versa. If you want to place the button outside Editor frame, then you would need it. When you implement the button according to the description above, the saved file will be sent to the server, yes

How great, but could you please give me a basic example how can i make a connection with Automation API in reactjs.

You’d need to add connector initialization to Editor’s initialization config, here is an example:

"events": {
                    "onDocumentReady": function ()
{
                        window.connector = docEditor.createConnector ();
                    }

After that you will be able to use Connector methods, here is an example:

function addComment ()
{
                connector.executeMethod ("AddComment", function(a) { console.log(a)
                });
 };

I tried to create a connection but the docEditor doesn’t exist in anywhere. Do i need to install several packages to resolve that error? Currently, Im using OnlyOffice Developer Edition free trial on Docker

Hello @ZangHoang,
We see that you have created a ticket in the Helpdesk system, communication regarding the issue will be continued there with priority. We will respond to you there shortly

1 Like