problem using InsertAndReplaceContentControls method

Integration questions/issues
Post Reply
Serhii
Posts: 6
Joined: Mon Dec 24, 2018 10:56 pm

problem using InsertAndReplaceContentControls method

Post by Serhii » Fri Dec 28, 2018 10:58 pm

Hi, I am trying to write plugin and got error "Download failed" i method InsertAndReplaceContentControls.

It works when I use the syntax

Code: Select all

window.Asc.plugin.executeMethod("InsertAndReplaceContentControls", [{Props:..., Script:...}]);
But I need to Insert another DOCX document as here https://github.com/ONLYOFFICE/sdkjs-plu ... nt/code.js

My code:

Code: Select all

(function (window) {
  window.Asc.plugin.init = function () {
    var obj = [{
      Props: {
        Id: 0,
        Tag: 'MyTag1;MyTag2',
        Lock: 0
      },
      Url: 'http://127.0.0.1/example/download?fileName=new%20(1).docx',
      // Url: 'http://127.0.0.1:5000/1.docx',
      Format: 'docx'
    }]
    window.Asc.plugin.executeMethod('InsertAndReplaceContentControls', [obj])
  }

  window.Asc.plugin.button = function (id) {
  }
})(window)
Screenshot with console:
screen_error.png
screen_error.png (93.86 KiB) Viewed 346 times
After the plugin execution I get error "Download failed" and empty Content Control created.
Is any way to insert one docx document into another?

Maxim
Posts: 1904
Joined: Tue Oct 11, 2016 2:34 pm

Re: problem using InsertAndReplaceContentControls method

Post by Maxim » Sat Dec 29, 2018 8:50 am

Hello Serhii!
I suppose the problem is described here

Serhii
Posts: 6
Joined: Mon Dec 24, 2018 10:56 pm

Re: problem using InsertAndReplaceContentControls method

Post by Serhii » Sat Dec 29, 2018 12:45 pm

I suppose the problem is described here
The Document editing service cannot upload the file for editing.
...
The link must be accessible from the document editing service.
What this means? Is any restrictions for document editing service such as domain or IP?
1) I tried to download the DOCX document on the same domain and port.
2) I tried to download one from my simple server on other port with CORS.
It fails.

Currently opened document opened successful and saves correctly, problem only when i click plugin in this line:

Code: Select all

window.Asc.plugin.executeMethod("InsertAndReplaceContentControls", [{Props:..., URL: 'http://DOCX_DOCUMENT_URL'}]);

Serhii
Posts: 6
Joined: Mon Dec 24, 2018 10:56 pm

Re: problem using InsertAndReplaceContentControls method

Post by Serhii » Sat Dec 29, 2018 1:38 pm

I just tried to use url from the sdkjs-plugins/examples/example_insert_content_and_document
and it works perfectly:

Code: Select all

window.Asc.plugin.executeMethod('InsertAndReplaceContentControls', [[{
    Props: {...},
    Url: 'https://personal.onlyoffice.com/products/files/httphandlers/filehandler.ashx?action=view&fileid=1617658&version=0&doc=aEE1OEk0THZWakI4bC9Ydm1CaFdQaGRpOFdLMURzaUFkV3cvRFlXS1dUND0_IjE2MTc2NTgi0',
    Format: 'docx'
  }]])
But i still not understand why my local urls don't work.

Post Reply