Search code examples
office365office-jsoffice-addinsword-addinsword-web-addins

Paragraph marks and hidden formatting symbols (¶) using Office JavaScript API code in Word add-in


Is it possible to add and remove paragraph marks and hidden formatting symbols(¶) using office js.

like this image


Solution

  • No, but you can to use the following code to insert breaks:

    // Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-body.yaml
    // Inserts a page break at the beginning of the document.
    // Run a batch operation against the Word object model.
    await Word.run(async (context) => {
      // Create a proxy object for the document body.
      const body = context.document.body;
    
      // Queue a command to insert a page break at the start of the document body.
      body.insertBreak(Word.BreakType.page, Word.InsertLocation.start);
    
      // Synchronize the document state by executing the queued commands, and return a promise to indicate task completion.
      await context.sync();
    
      console.log("Added a page break at the start of the document body.");
    });
    

    To submit a feature request for the Office JavaScript API, please post your idea to the Microsoft 365 Developer Platform Tech Community.