Try the fastest and simplest way to install ONLYOFFICE

Use current style when inserting content

Integration questions/issues

Use current style when inserting content

Postby 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.
bascouwenberg
 
Posts: 4
Joined: Fri Jun 08, 2018 5:16 am

Re: Use current style when inserting content

Postby Carl » Sat Jun 09, 2018 9:18 am

Hello,

could you please attach your document so we are able to analyze the issue?
Carl
 
Posts: 27
Joined: Thu Apr 12, 2018 10:00 am

Re: Use current style when inserting content

Postby 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: 4
Joined: Fri Jun 08, 2018 5:16 am

Re: Use current style when inserting content

Postby 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?
bascouwenberg
 
Posts: 4
Joined: Fri Jun 08, 2018 5:16 am

Re: Use current style when inserting content

Postby Maxim » Wed Jun 27, 2018 6:41 am

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

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

Re: Use current style when inserting content

Postby bascouwenberg » Fri Jun 29, 2018 1:52 pm

I've attached the file.
Attachments
onlyoffice.zip
(1.61 KiB) Downloaded 6 times
bascouwenberg
 
Posts: 4
Joined: Fri Jun 08, 2018 5:16 am


Return to API

Who is online

Users browsing this forum: No registered users and 0 guests

cron