Page 1 of 1

xdoc4j doesn't use embedded fonts from xdoc file?

PostPosted: Tue Jan 20, 2015 6:00 am
by Milan
Hi,

I embedded fonts using Word in my docx file. My program is copy of samples/convertOutPDF.java. If I run the program in Windows it is OK. When I run in linux some of Slovene special characters doesn't show correctly(čćžšđČĆŽŠĐ). I guess I don't know how to tell docx4j to use embedded fonts instead of OS fonts? When completed, the program will run in java server without fonts on disk. The solution without fonts embedded in xdoc, but somwhere in jar or folder where I copy them from Windows would be good to.

Today is the 3th day I know for docx4j. It looks very promising.

Thanks,
Milan

Re: xdoc4j doesn't use embedded fonts from xdoc file?

PostPosted: Tue Jan 20, 2015 4:04 pm
by jason
org.docx4j.fonts.fop.fonts.autodetect.UnixFontDirFinder (taken from FOP) tells docx4j where to find fonts on Unix, namely:

Code: Select all
            System.getProperty("user.home") + "/.fonts", // user
            "/usr/local/fonts", // local
            "/usr/local/share/fonts", // local shared
            "/usr/share/fonts", // system
            "/usr/X11R6/lib/X11/fonts" // X


Fonts embedded in the docx should be used. See org.docx4j.openpackaging.parts.WordprocessingML.ObfuscatedFontPart

Turn logging up for that class to see what is happening?

Looks like your code might need to do:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
                        FontTablePart fontTablePart= yourDocxPkg.getMainDocumentPart().getFontTablePart();     
                        fontTablePart.processEmbeddings();
 
Parsed in 0.014 seconds, using GeSHi 1.0.8.4


And use IdentityPlusMapper

If you're still having trouble you can attach a sample docx and I'll check it for you.

Re: xdoc4j doesn't use embedded fonts from xdoc file?

PostPosted: Wed Jan 21, 2015 3:48 am
by Milan
Jason,

Thank you for your help.
Using fontTablePart.processEmbeddings() now I see special characters correctly in pdf generated also in linux.

Regards,
Milan