bpetlur
bpetlur

Reputation: 383

Strikethrough option in docx4j java API

I have been using docx4j API to generate the word document in my project. Can any one please let me know whether docx4j API provides option to strikthrough the text in word document. I am not in position to use another word doc API to generate the word document

Thanks

Upvotes: 0

Views: 267

Answers (1)

JasonPlutext
JasonPlutext

Reputation: 15878

You can do pretty much anything with docx4j which the file formats allow.

You can generate code for a lot of that from a suitable sample docx with the Docx4j Webapp or Docx4j Helper Word AddIn, so in future, your first step should be to try that please.

Using the Word Addin just now, I generated:

            org.docx4j.wml.ObjectFactory wmlObjectFactory = new org.docx4j.wml.ObjectFactory();
            // Create object for rPr
            RPr rpr = wmlObjectFactory.createRPr(); 
            r.setRPr(rpr); 
                // Create object for strike
                BooleanDefaultTrue booleandefaulttrue2 = wmlObjectFactory.createBooleanDefaultTrue(); 
                rpr.setStrike(booleandefaulttrue2); 

This assumes you want to strike out the contents of an existing run R r, and that it doesn't already have rPr that you care about.

Upvotes: 1

Related Questions