Using docbuilder in C#

Good afternoon,
I’m trying to use Document Builder in my own C# application, I want to be able to edit documents. But I can’t find the API class from the example, tell me what I’m doing wrong:

  1. creating a project .NET Framework 4
  2. I connect the link only office doc builder
  3. I write the script to the button
    CONLYOFFICEDocBuilder builder = new CONLYOFFICEDocBuilder();
    builder.CreateFile(“docx”);
    var oDocument = Api.GetDocument();
    var oParagraph, oRun;
    oParagraph = oDocument.GetElement(0);
    oParagraph = Api.CreateParagraph();
    oParagraph.AddText(“Dear John Smith.”);
    oDocument.Push(oParagraph);
    oParagraph = Api.CreateParagraph();
    oParagraph.AddText(“ONLYOFFICE is glad to announce that starting today, you are appointed Commercial director to the company of your dream.”);
    oDocument.Push(oParagraph);
    oParagraph = Api.CreateParagraph();
    oRun = Api.CreateRun();
    oRun.SetBold(true);
    oRun.AddText("Please note: ");
    oParagraph.AddElement(oRun);
    oRun = Api.CreateRun();
    oRun.AddText(“this text is used to demonstrate the possibilities of “);
    oParagraph.AddElement(oRun);
    oRun = Api.CreateRun();
    oRun.SetBold(true);
    oRun.AddText(“ONLYOFFICE Document Builder”);
    oParagraph.AddElement(oRun);
    oRun = Api.CreateRun();
    oRun.AddText(” and cannot be used as real appointment to the position in any real company.”);
    oParagraph.AddElement(oRun);
    oDocument.Push(oParagraph);
    oParagraph = Api.CreateParagraph();
    oParagraph.AddText(“Best regards,”);
    oParagraph.AddLineBreak();
    oParagraph.AddText(“ONLYOFFICE Document Builder Team”);
    oDocument.Push(oParagraph);
    builder.SaveFile(“docx”, “SampleText.docx”);
    builder.CloseFile();

As a result, I can’t find the API class r1

If I’m trying to connect the library doctrenderer.dll , I get an error

“Unable to add a link to C:\Prrogram Files\ONLYOFFICE\DocumentBuilder\doctrenderer.dll Make sure that the file is available and is a valid COM assembly or component”

Tell me what I’m doing wrong. Or how to use docbuilder without creating scripts.

Hello @Irina
Please note that English is official language of this forum. Please rewrite your post.
As far as I understand you are looking for the way to edit files. Please pay attention that DocBuilder provides the opportunity to create\change files without web-editor. If you want to edit files in the browser\your app, you have to use Document server (DocBuilder is a part of it, so you can send requests to DocBuilder too).
If I misunderstood your request, please clarify it.

I’ll guess, it’s the problem, as described here:

https://forum.onlyoffice.com/t/net-wrapper-cant-add-doctrenderer-dll/3040

@Irina please confirm the assumption of @KlausR
Is the described situation related to mentioned thread?

that’s what I’m asking because I don’t know where to look for the API class

Hello @Irina
We have figured out the situation and we are going to fix it quickly with v.7.3 release (release is planned very soon). When v.7.3 is released, please use docbuilder.net.dll or docbuilder.com.dll.
Example: core/DesktopEditor/doctrenderer/docbuilder.net/test at master · ONLYOFFICE/core · GitHub
Sorry for inconvenience.

Thanks. Will wait.

1 Like