Page 1 of 1

Conversion Docx to HTML with Coldfusion

PostPosted: Mon Nov 04, 2019 9:54 pm
by e.esquivel
Hi all, I am trying to convert docx to HTML from a Colfusion webserver. After some hours to find the correct dependencies and jar files I finally was able to instanciate object from Coldfusion.
Maybe someone car help me or send me a link to follow.

A general comment on the website. There are a lot of broken links on the download page consulted 1/11/2019. I found what I need https://www.docx4java.org/docx4j/

The JRE is under Windows 2012. I am following the example at https://github.com/plutext/docx4j/blob/ ... tHtml.java

My issue:
I cannot create the BestMatchingMapper or initialize class org.docx4j.fonts.BestMatchingMapper. Maybe an issue with the mapper, it seems looking at org/apache/xmlgraphics/fonts/Glyphs but honsetly I am lost with not much error or log information.

I need the mapper for the wordMLPackage into an htmlSettings. Then to do a Docx4J.toHTML(htmlSettings, ByteArrayOutputStream, Docx4J.FLAG_EXPORT_PREFER_NONXSL);

Is there a way to define a path where to find the fonts when initialize the BestMatchingMapper ?

Log from Coldfusion
Code: Select all
Nov 4, 2019 11:19:37 AM Error [ajp-nio-8016-exec-7] - org/apache/xmlgraphics/fonts/Glyphs The specific sequence of files included or processed is: [path of the file], line: 87
11/04 11:20:05 [ajp-nio-8016-exec-8] INFO  Using paper size: A4
11/04 11:20:05 [ajp-nio-8016-exec-8] INFO  Landscape orientation: false
11/04 11:20:05 [ajp-nio-8016-exec-8] INFO  adding part with proposed name: /word/document.xml
11/04 11:20:05 [ajp-nio-8016-exec-8] INFO  adding part with proposed name: /word/styles.xml
11/04 11:20:05 [ajp-nio-8016-exec-8] INFO  adding part with proposed name: /docProps/core.xml
11/04 11:20:05 [ajp-nio-8016-exec-8] INFO  adding part with proposed name: /docProps/app.xml
11/04 11:20:05 [ajp-nio-8016-exec-8] INFO  adding part with proposed name: /word/settings.xml
Nov 4, 2019 11:20:05 AM Error [ajp-nio-8016-exec-8] - Could not initialize class org.docx4j.fonts.BestMatchingMapper The specific sequence of files included or processed is: [path of the file], line: 87

Re: Conversion Docx to HTML with Coldfusion

PostPosted: Wed Nov 06, 2019 6:51 am
by jason
I'd suggest you get it working in a Java environment first. That is, make sure you have all required deps.

Once you have that working, you can move to Coldfusion.

Regarding font mappers, BestMatchingMapper is most likely to be suitable on Linux or OSX systems which don't have Microsoft's fonts installed. Where it looks depends on your OS:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
        final String osName = System.getProperty("os.name");
        if (osName.startsWith("Windows")) {
            fontDirFinder = new WindowsFontDirFinder();
        } else {
            if (osName.startsWith("Mac")) {
                fontDirFinder = new MacFontDirFinder();
            } else {
                fontDirFinder = new UnixFontDirFinder();
            }
        }
 
Parsed in 0.015 seconds, using GeSHi 1.0.8.4


For where each of those look, see https://github.com/plutext/docx4j/tree/ ... autodetect