javasing 显示html,Docx4j在将html文档转换为docx时遇到一些样式问题(Docx4j having issue with some styles while converting...

在使用Docx4j将HTML文件转换为docx文档时,遇到背景颜色、边距、对齐方式等样式无法正确显示的问题。测试代码展示了转换过程,控制台输出显示了如何处理各种样式的问题。目前尚未找到解决样式丢失的方法。
摘要由CSDN通过智能技术生成

I have an issue with some styles after converting this html file to document.

div,p{

background-color: #ff0000;

padding: 100px;

border: 10px solid #000;

text-align: justify;

margin-bottom: 50px;

text-indent: 50px;

}

test test test
test test test
test test test

test test test
test test test
test test test

test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test

Using following unit test

@Test

public void testConvertXhtml3() throws Exception

{

String inputfilepath = "/Users/kyv/Documents/test.html";

// Create an empty docx package

WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage();

NumberingDefinitionsPart ndp = new NumberingDefinitionsPart();

wordMLPackage.getMainDocumentPart().addTargetPart(ndp);

ndp.unmarshalDefaultNumbering();

XHTMLImporterImpl xHTMLImporter = new XHTMLImporterImpl(wordMLPackage);

// Convert the XHTML, and add it into the empty docx we made

wordMLPackage.getMainDocumentPart().getContent().addAll(xHTMLImporter.convert(new File(inputfilepath), null) );

wordMLPackage.save(new java.io.File("/Users/kyv/Documents/test.docx") );

}

In console I get a lot of "How to handle: ..." Part of log

Attempting to load: docx4j.properties

Using paper size: A4

Landscape orientation: false

Set contentType application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml on part /

java.vendor=Oracle Corporation

java.version=1.7.0_55

jar:file:/Users/kvn/.m2/repository/com/sun/xml/bind/jaxb-impl/2.2.3-1/jaxb-impl-2.2.3-1.jar!/META-INF/MANIFEST.MF

Implementation-Title : JAXB Reference Implementation

Implementation-Version : 2.2.3

Class-Path : jaxb-api.jar activation.jar jsr173_1.0_api.jar jaxb1-impl.jar

Manifest-Version : 1.0

Specification-Vendor : Oracle Corporation

Created-By : 1.5.0_22-b03 (Sun Microsystems Inc.)

Ant-Version : Apache Ant 1.7.1

Implementation-Vendor : Oracle Corporation

Implementation-Vendor-Id : com.sun

Specification-Title : Java Architecture for XML Binding

Specification-Version : 2.2.2

Extension-Name : com.sun.xml.bind

Build-Id : hudson-jaxb-ri-2.2.3-3

Found JAXB reference implementation in jar:file:/Users/kushniry/.m2/repository/com/sun/xml/bind/jaxb-impl/2.2.3-1/jaxb-impl-2.2.3-1.jar!/META-INF/MANIFEST.MF

Implementation-Version : 2.2.3-hudson-jaxb-ri-2.2.3-3-

Attempting to load: org/docx4j/wml/jaxb.properties

Not using MOXy, since no resource: org/docx4j/wml/jaxb.properties

No MOXy JAXB config found; assume not intended..

org/docx4j/wml/jaxb.properties not found via cla

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值