How to Create a Word Document Using Blazor Word (DocIO) Library

Поділитися
Вставка
  • Опубліковано 12 лис 2024

КОМЕНТАРІ • 5

  • @FireMaster666Gamer
    @FireMaster666Gamer Рік тому

    can you do something like this but transforming a blazor page into a word?

    • @SyncfusionInc
      @SyncfusionInc  Рік тому

      Hi,
      From the given details, we have found that your requirement is to convert the Blazor page (Razor) to a Word document.
      Using Syncfusion Word (DocIO) library, you can convert the HTML to a Word document.
      To achieve your requirement, we suggest you get the Blazor page in HTML format. Then using the DocIO library, you can either convert the HTML file to a Word document or you can insert or add an HTML string into the Word document.
      Refer to our UG documentation link to know about how to convert an HTML file to a Word document,
      help.syncfusion.com/file-formats/docio/html
      Refer to our UG documentation link to know about how to insert or add HTML string into the Word document,
      help.syncfusion.com/file-formats/docio/html#customizing-the-html-to-word-conversion

  • @NetworkPI-l6e
    @NetworkPI-l6e Рік тому

    Hello Sir, how to do normal and bold on one paragraph like this: This is *content*

    • @SyncfusionInc
      @SyncfusionInc  Рік тому

      Hi,
      Thank you for reaching out.
      To do normal and bold on one paragraph like “This is content”, we suggest you add the text to the paragraph and set the Bold property of the character format as true for particular text like “content”. Please use the below-highlighted code snippet,
      //Create a new Word document.
      using (WordDocument document = new WordDocument())
      {
      //Add new section to the document.
      IWSection section = document.AddSection();
      //Add new paragraph to the section.
      IWParagraph firstParagraph = section.AddParagraph();
      //Add new text to the paragraph.
      IWTextRange firstText = firstParagraph.AppendText("This is ");
      IWTextRange secondText = firstParagraph.AppendText("content");
      //Set bold to the text.
      secondText.CharacterFormat.Bold = true;
      //Save the Word document to MemoryStream
      MemoryStream stream = new MemoryStream();
      document.Save(stream, FormatType.Docx);
      }
      Please refer to our UG documentation link to know more about how to format the text in the Word document,
      help.syncfusion.com/file-formats/docio/working-with-paragraph#working-with-text.

    • @NetworkPI-l6e
      @NetworkPI-l6e Рік тому

      @@SyncfusionInc Thank you very much, Sir