question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Strike and underline don't work in Word when used together

See original GitHub issue

Hi there, I need an ability to use both strike and underline at the same time. It works great for Google docs but doesn’t work for Word web version. Also text color and font size doesn’t work. Here is code, I took it from example and changed a bit:

const fs = require("fs");
const docx = require("docx");
const {ExternalHyperlink} = require("docx");
const { Document, Packer, Paragraph, TextRun } = docx;
// Documents contain sections, you can have multiple sections per document, go here to learn more about sections
// This simple example will only contain one section
const doc = new Document({
    sections: [
        {
            properties: {},
            children: [
                new Paragraph({
                    alignment: 'center',
                    children: [
                        new TextRun({
                            text: "Foo Bar",
                            strike: true,
                            underline: true,
                            italics: true,
                            color: '#e30e0e',
                            size: 50,
                        })
                    ]
                })
            ],
        },
    ],
});

// Used to export the file into a .docx file
Packer.toBuffer(doc).then((buffer) => {
    fs.writeFileSync("My Document.docx", buffer);
});

// Done! A file called 'My Document.docx' will be in your file system.

And here is screenshot of result: Screen Shot 2022-10-19 at 8 22 45 PM

Also if problem is confirmed, maybe you have any suggestions on how to overcome it before problem is solved?

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
dolanmiucommented, Oct 25, 2022

That is strange that there is an inconsistency there

I have found a fix though

I have updated demo 2 to reflect this

Essentially, you create a style, then apply the style to the run or paragraph

0reactions
VLaSHcommented, Oct 25, 2022

That works fine! Thank you very much for your help and time!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How can i both underline and strikeout text within a footnote?
I'm working with a legal document that makes extensive use of footnotes. The author wants to underline some text, and strike through other ......
Read more >
How to Underline, Strikethrough, Subscript, ... in MS Word
Get Microsoft Word *: https://amzn.to/33GMhoq Don't want to wait for ... This also works with Microsoft Office on a Mac and also with...
Read more >
Strikethrough in Word w/ Keyboard Shortcuts - YouTube
Learn how to strikethrough text in Microsoft Word using your keyboard shortcuts (it's fast!)SUBSCRIBE to get our latest PowerPoint tips and ...
Read more >
Count of Underlined or Struck-Through Words
Still, if your words use simple underlining or simple strikethrough, then these steps will work quickly and easily.
Read more >
How to find whether strikeThrough /underline is present in ...
Use the search method in the Word.Body object.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found