Search code examples
javasymbolsoverlapdocx4j

How to write specific symbols to Docx file using docx4j


I have specific logical symbols like ⇒,∨,∧,¬ and I want to write text with these symbols to docx document. With short symbols ∨,∧,¬ all fine, but symbol ⇒ overlaps with next character like enter image description here

but it should look like

enter image description here

My code looks like

MainDocumentPart mdp = wordMLPackage.getMainDocumentPart();    
P p = factory.createP();
R run = factory.createR();
p.getContent().add(run);
Text text = factory.createText();
text.setValue("((q⇒p)∧q)⇒p");
run.getContent().add(text);
mdp.addObject(p);

How to correct writing long symbols like ⇒?


Solution

  • You can use docx4j code generation to get what you want.

    Create a document in Word which looks how you want it, then save as docx.

    To generate code based on that docx, do one of the following:

    1. upload it to http://webapp.docx4java.org/OnlineDemo/PartsList.html

    or 2. install/use our Word AddIn; get it at http://www.docx4java.org/forums/docx4jhelper-addin-f30/docx4j-helper-addin-v1-final-available-t2253.html

    If you are still having problems, post the XML you created in Word, or the code you generated following the above steps.