Use current style when inserting content

Integration questions/issues
Post Reply
bascouwenberg
Posts: 5
Joined: Fri Jun 08, 2018 5:16 am

Use current style when inserting content

Post by bascouwenberg » Fri Jun 08, 2018 5:25 am

I am using OnlyOffice Integration and I wrote a plugin to insert text in a document. In this case the document has the Arial font but when I insert text it doesn't have the same font as the document. Instead it has the Georgia font.
How can I make sure whenever I insert text it gets the font used in the document or even better the style at the current cursor position?

The code:

Code: Select all

var sScript = "var oDocument = Api.GetDocument();";
        sScript += "var oParagraph = Api.CreateParagraph();";
        sScript += "oParagraph.AddText(\"";
        sScript += text;
        sScript += "\");";
        sScript += "oDocument.InsertContent([oParagraph]);";
        window.Asc.plugin.info.recalculate = true;
        window.Asc.plugin.executeCommand("command", sScript);
I also tried callCommand with the same result as above.
Last edited by bascouwenberg on Thu Jun 14, 2018 1:54 pm, edited 1 time in total.

Carl
Posts: 92
Joined: Thu Apr 12, 2018 10:00 am

Re: Use current style when inserting content

Post by Carl » Sat Jun 09, 2018 9:18 am

Hello,

could you please attach your document so we are able to analyze the issue?

bascouwenberg
Posts: 5
Joined: Fri Jun 08, 2018 5:16 am

Re: Use current style when inserting content

Post by bascouwenberg » Thu Jun 14, 2018 1:53 pm

For some reason I cannot attach a rtf file. Nothing happens when I try to. It is a simple file with some example text that has the Arial font. And when I now insertsome text into the document it doesn't have the Georgia font as a said earlier but the Liberation Serif font. The version of OnlyOffice is 5.1.3.

bascouwenberg
Posts: 5
Joined: Fri Jun 08, 2018 5:16 am

Re: Use current style when inserting content

Post by bascouwenberg » Tue Jun 19, 2018 7:16 am

I get an error that the extensions rtf and docx are not allowed as attachments. What can I use to upload a document?

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

Re: Use current style when inserting content

Post by Maxim » Wed Jun 27, 2018 6:41 am

Hello bascouwenberg!
What can I use to upload a document?
ZIP

bascouwenberg
Posts: 5
Joined: Fri Jun 08, 2018 5:16 am

Re: Use current style when inserting content

Post by bascouwenberg » Fri Jun 29, 2018 1:52 pm

I've attached the file.
Attachments
onlyoffice.zip
(1.61 KiB) Downloaded 24 times

bascouwenberg
Posts: 5
Joined: Fri Jun 08, 2018 5:16 am

Re: Use current style when inserting content

Post by bascouwenberg » Fri Sep 14, 2018 7:36 am

Are there any updates on this problem?

Post Reply