简体   繁体   English

docx4j Java API中的删除线选项

[英]Strikethrough option in docx4j java API

I have been using docx4j API to generate the word document in my project. 我一直在使用docx4j API在我的项目中生成word文档。 Can any one please let me know whether docx4j API provides option to strikthrough the text in word document. 谁能让我知道docx4j API是否提供选项来删除Word文档中的文本。 I am not in position to use another word doc API to generate the word document 我无法使用其他Word文档API生成Word文档

Thanks 谢谢

You can do pretty much anything with docx4j which the file formats allow. 您可以使用docx4j进行几乎所有文件格式允许的操作。

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. 您可以使用Docx4j Webapp或Docx4j Helper Word插件从合适的示例docx中生成大量代码,因此将来,您的第一步应该是尝试一下。

Using the Word Addin just now, I generated: 刚才使用Word Addin,我生成了:

            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. 假设您要删除现有运行R r的内容,并且它还没有要关注的rPr。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM