简体   繁体   中英

How Docx4j interprets css

I'm soon tearing my hair off but I'm really struggling with how docx4j interprets CSS when converting xhtml to a docx-file.

I've tried googling and I keep getting back to reading the sourcecode for the entire project in order to figure ut out.

For example I found out that font-sizes are only interpreted when in pt and not in px, em or any of the other sizes. And that by reading this link

Also, if anyone could be so kind as to help me with font-face which just doesn't seem to work.

Is there anyone out here that can explain how or has any documentation as to how it works?

* Disclosure: I wrote the relevant docx4j code *

There are two parts to it.

The first is Flying Saucer / XHTML Renderer.

The second is the code in docx4j which converts what it gets from Flying Saucer to WordML.

As you've discovered, there are some things which docx4j doesn't convert yet (font face being one of them). Not because they are particularly hard, but just because our priorities have been elsewhere. You are welcome to add whatever you need and contribute a patch.

For simple stuff like you mention, the starting point is the addRunProperties method at line 1327 of XHTMLImporter. There you can see the CSSValue objects provided by Flying Saucer. I presume you've found the docx4j source code on GitHub.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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